How to set Site Closure and deletion Policy in SharePoint Online using CSOM?

Hello SharePointers,

Here is the Powershell code to set the site closure and deletion policy in Sharepoint online.

$policies = [Microsoft.SharePoint.Client.InformationPolicy.ProjectPolicy]::GetProjectPolicies($web.Context, $web)
$web.Context.Load($policies)
$web.Context.ExecuteQuery()

$policy = $policies | ?{$_.Name -eq ” Office Policy”}

if ($policy) {

# Apply the policy.
[Microsoft.SharePoint.Client.InformationPolicy.ProjectPolicy]::ApplyProjectPolicy($web.Context, $web, $policy)
$web.Update()
$web.Context.ExecuteQuery()

Happy SharePointing Folks 🙂

Leave a Reply

Your email address will not be published.