Updating SharePoint 2013 Record Declaration settings with Powershell


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.

RecordSettingsPage

 

 

 

 

 

 

 

 

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.

ecm_siterecorddeclarationby

ecm_siterecorddeclarationdefault

ecm_siterecordrestrictions

ecm_siterecordundeclarationby

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.

SharePoint manager

You can play around with the settings through the UI, save them, then inspect the values using SharePoint manager.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s