Locking and Unlocking a Site in Sharepoint 2010

Locking and Unlocking a Site

In order to change the lock status of a SharePoint site using SharePoint 2010 Management Shell, the following Powershell script can be used:

  • Set-SPSite -Identity "<SiteCollectionUrl>" -LockState "<LockState>"

Where:

"<SiteCollectionUrl>" is the url of the SharePoint site you wish to lock e.g "http://mysharepoint/sites/mysite",

"<LockState>" specifies the the nature of restriction you want to impose on the specified site. The following are the possible lock states and their description:

  1. "ReadOnly"

    Prevents SharePoint users from making updates, additions and deletion of items on the site.

  2. "NoAccess"

    This lock state prevents SharePoint users from accessing the specified site collection and its contents. If users attempt to access the site they receive an error in the form of a white page with error message "403 FORBIDDEN".

  3. "Unlock"

    This lock state releases locks on the SharePoint site and allows users access to the site and its functionality.

  4. "NoAdditions"

    Although updates and deletions are still permitted when this lock state is implemented, addition of new content on the SharePoint site are not possible.

For example, if one wants to disable updates , additions and deletion of items on a SharePoint site at address "http://mysharepoint/sites/mysite" , the following Powershell script will be used:

  • Set-SPSite -Identity "http://mysharepoint/sites/mysite" -LockState "ReadOnly"
Retrieving the status of the site locks

In order to get information on the restriction imposed on a site the following Powershell command can be used:

 

  • Get-SPSite "<SiteCollectionUrl>" | Select [Readlocked],[Writelocked],[ReadOnly]

Where:

  • "<SiteCollectionUrl>" - is the url of the SharePoint site you wish to lock e.g "http://mysharepoint/sites/mysite",

And Readlocked, Writelocked,ReadOnly are boolean properties of the site that can be either true or false depending on the restrictions implemented on the site.

For example if one wants to get the states of the site with respect to its ReadOnly state one would use the following script:

  • Get-SPSite "http://mysharepoint/sites/mysite" | Select ReadOnly
Ebook Download
View all
Learn
View all