Monday, January 30, 2012

PowerShell: Lock/Unlock Site Collections

Simple enough: locks or unlocks sites (change the -LockState flag to either relfect "ReadOnly" or "Unlock"). Faster than changing the Delta value on a content database to prevent new sites from being created...

$webApp = Get-SPWebApplication "web_application_name_here"
foreach ($site in $webApp.Sites)
          for($i=0; $i -lt $site.AllWebs.Count; $i++)
               // Set to "ReadOnly" to lock; "Unlock" to unlock.
               Set-SPSite -Identity $site -LockState "Unlock"

No comments:

Post a Comment