Vstupní parametry:
- webAppUrl – URL adresa webové aplikace
- lockState
- ReadOnly = zamčení pouze pro čtení
- Unlock = odemčení zpět pro editaci
Příklad:
.\SetLockStateInAllSiteCollections.ps1 -webAppUrl http://srvdev:81/ -lockState ReadOnly
<#
.Synopsis
Sets/removes all site collection lock in web application
.Example
.\SetLockStateInAllSiteCollections.ps1 -webAppUrl http://srvdev:81/ -lockState ReadOnly
.\SetLockStateInAllSiteCollections.ps1 -webAppUrl http://srvdev:81/ -lockState Unlock
.Notes
NAME: SetLockStateInAllSiteCollections.ps1
AUTHOR: novotny@devit.cz
.Link
http://www.devit.cz
#>
param (
[Parameter(Mandatory=$True)]
[string]$webAppUrl,
[Parameter(Mandatory=$True)]
[string]$lockState
)
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$webApp = Get-SPWebApplication $webAppUrl
$allSites = $webApp | Get-SPSite
foreach ($site in $allSites)
{
Write-Host "Setting " -nonewline
Write-Host $site.url -nonewline
Write-Host " to $lockState..." -nonewline
Set-SPSiteAdministration -LockState $lockState -Identity $site.url
Write-Host "[OK]" -foregroundcolor green
}