How To Configure IRM In SharePoint Online/Office 365 Using CSOM

The users can restrict the permission of the content documents and the E-mail messages in Office Online by using Information Rights Management (IRM). Site collection admin can configure which IRM options are available to your organization by using Group Policy.

First, create a client context, using Office 365 site and load the required document library, which is stored in $Lists. Access the IRmenabled properties and make it to true and set the title of the new IRM policy.

The properties given below are available for the manipulation.
  1. AllowWriteCopy.
  2. DisableDocumentBrowserView.
  3. DocumentLibraryProtectionExpireDate.
  4. DocumentAccessExpireDays.
  5. EnableDocumentAccessExpire.
  6. EnableDocumentBrowserPublishingView.
  7. EnableGroupProtection.
  8. EnableLicenseCacheExpire.
  9. LicenseCacheExpireDays.
  1. $ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext(“”http://mysharepointsite”)  
  2. $CCreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)  
  3. $ClientContextContext.Credentials = $CCreds  
  4. $Lists = $Context.Web.Lists  
  5. $ClientContextContext.Load($Lists)  
  6. $ClientContextContext.ExecuteQuery()  
  7. $List = $Lists.GetByTitle(“Documents”)  
  8. $Context.Load($List)  
  9. $Context.ExecuteQuery()  
  10. $List.IrmEnabled = $true  
  11. $List.InformationRightsManagementSettings.PolicyDescription = “My Policy”  
  12. $List.InformationRightsManagementSettings.PolicyTitle =”My Policy Name”  
  13. $List.InformationRightsManagementSettings.AllowPrint = $false  
  14. $List.InformationRightsManagementSettings.AllowScript = $true  
  15. $List.InformationRightsManagementSettings.AllowWriteCopy = $true  
  16. $List.InformationRightsManagementSettings.DisableDocumentBrowserView = $false  
  17. $List.InformationRightsManagementSettings.DocumentLibraryProtectionExpireDate = #Date  
  18. $List.InformationRightsManagementSettings.DocumentAccessExpireDays = 10  
  19. $List.InformationRightsManagementSettings.EnableDocumentAccessExpire = $true  
  20. $List.InformationRightsManagementSettings.EnableDocumentBrowserPublishingView = $true  
  21. $List.InformationRightsManagementSettings.EnableGroupProtection = $true  
  22. $List.InformationRightsManagementSettings.EnableLicenseCacheExpire $true  
  23. $List.InformationRightsManagementSettings.LicenseCacheExpireDays = 15  
  24. $List.InformationRightsManagementSettings.GroupName = “mygrp:  
  25. $List.Update()  
  26. $ClientContext.ExecuteQuery()
Ebook Download
View all
Learn
View all