Write Power Shell Script to Lock and Unloock a Site in SharePoint 2010

Below Power Shell Script will Unlock a SharePoint site if it is in locked/read-only.

#Region variable declaration
Write-Host "UnLock status started....."
Add-PSSnapin Microsoft.Sharepoint.Powershell
Set-SPSite -Identity "<site-url>" -LockState "Unlock"
Write-Host "Task completed....."
Read-Host -Prompt "The above error occurred. Press Enter to exit."


For -LockState attribute there are mainly 4 parameters that can be used:

Unlock - To unlock site collection and make it available to users.
NoAdditions - Prevent users from adding new content to the site collection. Updates and deletions are still allowed.
ReadOnly - Prevent users from adding, updating, or deleting content.
NoAccess - Prevent users from accessing the site collection and its content.

Comments

Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX