Get Information Rights Management for entire SharePoint farm using PowerShell

This SharePoint tutorial, we will discuss what is information rights management? How to use information management service in SharePoint Online to protect lists and libraries. And, how to get Information Rights Management for the entire farm using PowerShell Scripts.

Working on the Migration Project from SharePoint On-premises to SharePoint Online. Don’t miss the IRM information of your existing SharePoint applications. IRM is a very important feature of SharePoint and matters a lot for organization governance policy.

Information Rights Management (IRM) in SharePoint

Within SharePoint Online, IRM protection is applied to files at the list and library level. Before your organization can use IRM protection, you must first set up Rights Management.

Setup Information Rights Management (IRM) in SharePoint Online

Use the below steps to configure information management service in SharePoint Online to protect list and libraries.

  • Navigate to the SharePoint Admin center.
  • Navigate to the Settings page
  • Navigate to Information Rights Management (IRM) section select “Use the IRM service specified in your configuration”.
  • Select “Refresh IRM Settings”.
  • Now site owners can protect their SharePoint lists and document libraries. Let’s configure IRM for lists and libraries.
  • Navigate to the list or library for which you want to configure IRM settings.
  • Click on Library Settings from Ribbon.
  • Now you are on the Library settings page which will have the Permission and Management Section.
  • Click on Information Rights Management for further configuration.
  • Select Restrict permission to documents in this library on the download checkbox which will further restrict permission to documents that are downloaded.
  • Provide appropriate policy name and description in policy title and description respectively.
  • You can also provide additional restrictions to list and libraries documents.
  • Click OK to complete the configuration settings.

Get Information Rights Management for entire SharePoint farm using PowerShell

Please find below PowerShell for further reference which will get Information Rights Management for the entire SharePoint farm using PowerShell.

$ver = $host | select version
if($Ver.version.major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell -ea 0))
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
cls
try{
#Specify a directory for which to log the results
$0 = $MyInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)
$LoggingDirectory = $dp0
$logFile=$("$dp0\Logs\EntireFarm_IRM_LogInformation.txt")
$ExecutionStartTime = (Get-Date -UFormat "%Y-%m-%d_%I:%M:%S %p").tostring()
Write "Script started at" $ExecutionStartTime >> $logFile
Write-Host "Script started at" $ExecutionStartTime
$PageLayout_Webparts_DetailsCSV =@()
#Create a variable based on the current date and time
$StartTime = (Get-Date -UFormat "%Y-%m-%d_%I-%M-%S %p").tostring()

#Dynamically generate the log file name
$Filename = "$LoggingDirectory\Result\EntireFarm_IRM_Details_" +$StartTime +".csv"

#Create Column Headers of csv
#’WebURL,List,Flag,FolderURL,FolderName’ | Out-File $Filename -Append;

$webapplist = Get-SPWebApplication
foreach($webappUrl in $webapplist){
try{
#Specify the Web Application to be targeted
$WebApplicationURL = $webappUrl.Url

#Write "`r`n web application URL" $WebApplicationURL "is being investigated" >> $logFile

#Get all sites within each of the specified web application
$AllSites = Get-SPSite -WebApplication $WebApplicationURL -Limit All
#$AllSites = Get-SPSite $WebApplicationURL -Limit All

foreach($Site in $AllSites){
Write "`r`nInside Site'" + $Site.Url >> $logFile
try{
#Return all webs in each site collection returned to the AllWebs variable
$AllWebs = $Site.Allwebs

#Perform some actions against each web retrieved from the current target site collection
foreach($Web in $AllWebs){
try{
$AllList = $Web.Lists
foreach($List in $AllList){
#Write-Host $List.Title ‘|’ $List.IrmEnabled
if($List.IrmEnabled){
Write "============================================================================" >> $logFile
Write $List.InformationRightsManagementSettings.PolicyTitle >> $logFile
Write $List.InformationRightsManagementSettings.PolicyDescription >> $logFile
Write $List.IrmReject >> $logFile
write $List.IrmExpire >> $logFile
Write $List.InformationRightsManagementSettings.DocumentLibraryProtectionExpireDate >> $logFile
Write $List.InformationRightsManagementSettings.DisableDocumentBrowserView >> $logFile
Write $List.InformationRightsManagementSettings.AllowPrint >> $logFile
Write $List.InformationRightsManagementSettings.AllowScript >> $logFile
Write $List.InformationRightsManagementSettings.AllowWriteCopy >> $logFile
Write $List.InformationRightsManagementSettings.EnableDocumentAccessExpire >> $logFile
Write $List.InformationRightsManagementSettings.DocumentAccessExpireDays >> $logFile
Write $List.InformationRightsManagementSettings.EnableLicenseCacheExpire >> $logFile
Write $List.InformationRightsManagementSettings.EnableGroupProtection >> $logFile
Write $List.InformationRightsManagementSettings.GroupName >> $logFile
Write "============================================================================" >> $logFile

$PageLayout_Webparts_DetailsCSV+=New-Object PSObject -Property @{
WebURL=$Site.Url;
WebTitle=$Web.Title;
ListName=$List.Title;
ListURL=$List.DefaultViewUrl;
IrmEnabled=$List.IrmEnabled;
PolicyTitle=$List.InformationRightsManagementSettings.PolicyTitle;
PolicyDescription=$List.InformationRightsManagementSettings.PolicyDescription;
IrmReject=$List.IrmReject;
IrmExpire=$List.IrmExpire;
DocumentLibraryProtectionExpireDate = $List.InformationRightsManagementSettings.DocumentLibraryProtectionExpireDate;
DisableDocumentBrowserView=$List.InformationRightsManagementSettings.DisableDocumentBrowserView;
AllowPrint=$List.InformationRightsManagementSettings.AllowPrint;
AllowScript=$List.InformationRightsManagementSettings.AllowScript;
AllowWriteCopy=$List.InformationRightsManagementSettings.AllowWriteCopy;
EnableDocumentAccessExpire=$List.InformationRightsManagementSettings.EnableDocumentAccessExpire;
DocumentAccessExpireDays=$List.InformationRightsManagementSettings.DocumentAccessExpireDays;
EnableLicenseCacheExpire=$List.InformationRightsManagementSettings.EnableLicenseCacheExpire;
EnableGroupProtection=$List.InformationRightsManagementSettings.EnableGroupProtection;
GroupName=$List.InformationRightsManagementSettings.GroupName}

}
}
$Web.Dispose()
}
catch [Exception]{
Write $_.Exception|format-list -force >>$logFile
Write-Host -f red $_.Exception|format-list -force
}
finally{
if($Web){
$Web.Dispose()
}
}
}
$Site.Dispose()
}
catch [Exception]{
Write $_.Exception|format-list -force >>$logFile
Write-Host -f red $_.Exception|format-list -force
}
finally{
if($Site){
$Site.Dispose()
}
}
}

}
catch [Exception]{
Write $_.Exception|format-list -force >>$logFile
Write-Host -f red $_.Exception|format-list -force
}

}
$PageLayout_Webparts_DetailsCSV | Export-CSV -path $Filename -notype

}
catch [Exception]{
Write $_.Exception|format-list -force >>$logFile
Write-Host -f red $_.Exception|format-list -force
}
$EndTime = (Get-Date -UFormat "%Y-%m-%d_%I:%M:%S %p").tostring()
Write "Script stopped at" $EndTime >> $logFile
Write-Host "Script stopped at" $EndTime

You may like following SharePoint tutorials:

Here, we learned how to get information rights management for the entire SharePoint farm using PowerShell in SharePoint 2013/2106

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>