Prior to migrating content from one environment to another, it is important to lock or write-protect a particular site-collection. This will help to ensure that your users will not lose site changes they are making. The following PowerShell script will allow you to set the ReadOnly and WriteLocked property of the site collection. Line three of the following script will allow you to toggle the property as needed.


The Script


# Specify the site collection url

$siteURL = http://ps-moss/”

$setLock = $true

# Load the Microsoft.SharePoint DLL

[void][system.reflection.assembly]::load(“Microsoft.Sharepoint, version=, culture=neutral, publickeytoken=71e9bce111e9429c”)

# Create a new site object using the siteURL –> This will require a Dispose

$site = new-object Microsoft.SharePoint.SPSite($siteURL)

$site.WriteLocked = $setLock

$site.ReadOnly = $setLock

# Review the properties of the site


# Dispose of the site object


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