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>"
"<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:
- "ReadOnly"
Prevents SharePoint users from making updates, additions and deletion of items on the site.
- "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".
- "Unlock"
This lock state releases locks on the SharePoint site and allows users access to the site and its functionality.
- "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.
- Set-SPSite -Identity "http://mysharepoint/sites/mysite" -LockState "ReadOnly"
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]
- "<SiteCollectionUrl>" - is the url of the SharePoint site you wish to lock e.g "http://mysharepoint/sites/mysite",
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
Comments