I had a requirement to enable the In Place Records Management feature on a number of SharePoint 2013 sites and configure the declarations settings for each site. I had around 70+ site collections to update so I turned to PowerShell to allow me to automate the process.
If you navigate to the records declaration setting of the site collection you will be presented with the dialog below.
Firstly you need to enable the In Place Records Management feature on all sites and this can be done easily with the following script:
Enable-SPFeature -Identity "RecordsManagement" -URL $row.WebUrl -ErrorAction SilentlyContinue
But how do we now automate the settings with Powershell?
Each site collection has an AllProperties collection that contains various settings for the site. In this collection you will find the following entries relating to the record declaration settings from the dialog above.
You can modify these settings using the script below.
$site = Get-SPSite $row.WebUrl -ErrorAction SilentlyContinue $site.RootWeb.AllProperties["ecm_siterecordrestrictions"] = "BlockDelete, BlockEdit" $site.RootWeb.AllProperties["ecm_siterecorddeclarationdefault"] = "True" $site.RootWeb.AllProperties["ecm_siterecordundeclarationby"] = "OnlyAdmins" $site.RootWeb.AllProperties["ecm_siterecorddeclarationby"] = "OnlyAdmins" $site.RootWeb.Update()
You might wondering how you find the values for these settings.
Well I like to use a tool called SharePoint Manager 2013 that allows you to inspect the properties collections of all the sites and much more.
You can play around with the settings through the UI, save them, then inspect the values using SharePoint manager.