IRM enabling using PowerShell on SP online list


Here’s my script to set IRM settings in SharePoint online library.

$site = “https://Domain.sharepoint.com/sites/****”
$Context = Get-ClientContext $Username $password $site
$list = $Context.Web.Lists
$context.Load($list)
$context.ExecuteQuery()
Foreach($lists in $list)
{
if($lists.BaseType -eq “DocumentLibrary” -and $lists.Hidden -eq $false)
{
write-host $lists
set-SPOList -ListName $lists
$lists.IrmEnabled =$true
$lists.InformationRightsManagementSettings.PolicyTitle = “RMSDefaultPolicy”
$lists.InformationRightsManagementSettings.PolicyDescription = “Default RMS Policy”
$lists.IrmReject = $true
write-host “hi i am executing”
$lists.InformationRightsManagementSettings.AllowPrint = $true
$lists.InformationRightsManagementSettings.EnableLicenseCacheExpire = $true
$lists.InformationRightsManagementSettings.LicenseCacheExpireDays = “8”
$lists.Update()
$context.ExecuteQuery()
write-Host $lists.Title + “hi”
}

}

References:

https://thesharepointfarm.com/2013/07/using-powershell-to-manage-sharepoint-information-rights-management-settings/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s