How to Configure IRM in SharePoint Online/Office 365 using CSOM?

Hello SharePointers,

In this blog, we will see how to configure IRM using CSOM in SharePoint online/ Office 365.

 

$ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext(“”http://mysharepointsite”)
$CCreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)
$ClientContextContext.Credentials = $CCreds

$Lists = $Context.Web.Lists
$ClientContextContext.Load($Lists)
$ClientContextContext.ExecuteQuery()
$List = $Lists.GetByTitle(“Documents”)
$Context.Load($List)
$Context.ExecuteQuery()
$List.IrmEnabled = $true
$List.InformationRightsManagementSettings.PolicyDescription = “My Policy”
$List.InformationRightsManagementSettings.PolicyTitle =”My Policy Name”
$List.InformationRightsManagementSettings.AllowPrint =  $false
$List.InformationRightsManagementSettings.AllowScript = $true
$List.InformationRightsManagementSettings.AllowWriteCopy = $true
$List.InformationRightsManagementSettings.DisableDocumentBrowserView = $false
$List.InformationRightsManagementSettings.DocumentLibraryProtectionExpireDate = #Date
$List.InformationRightsManagementSettings.DocumentAccessExpireDays = 10
$List.InformationRightsManagementSettings.EnableDocumentAccessExpire = $true
$List.InformationRightsManagementSettings.EnableDocumentBrowserPublishingView = $true
$List.InformationRightsManagementSettings.EnableGroupProtection = $true
$List.InformationRightsManagementSettings.EnableLicenseCacheExpire $true
$List.InformationRightsManagementSettings.LicenseCacheExpireDays = 15
$List.InformationRightsManagementSettings.GroupName = “mygrp:
$List.Update()
$ClientContext.ExecuteQuery()

Happy SharePointing Folks 🙂

Leave a Reply

Your email address will not be published.