Pages

11 November 2011

Lock or Unlock all Site Collection in a Web Application

ISSUE DESCRIPTION:
For many reason, like a maintenance window on a SharePoint Farm, you might want to lock all the site collection from a Web Application

SOLUTION:
I have created an automated script that will do that for you.

SPSiteCollectionLockScript:

param (
    [string]$WebAppUrl = $(throw "Missing WebApp URL (please use -webappurl [URL])"),
    [string]$LockState= $(throw "Missing LockState (please use -lockstate [Unlock/ReadOnly])")
)

#Addin SharePoint2010 PowerShell Snapin
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

$WebApp = Get-SPWebApplication $WebAppUrl
$AllSites = $WebApp | Get-SPSite

#Set each SiteCollection with the lockstate defined
foreach ($Site in $AllSites)
    {
    Write-Host "Setting " -nonewline
    Write-Host $Site.url -ForegroundColor Yellow -nonewline
    Write-Host " to $lockState..." -nonewline
    Set-SPSiteAdministration -LockState $lockState -Identity $Site.url
    Write-Host "[OK]" -foregroundcolor green
    }

Paste the above code in a PowerShellScript file, like [SPSiteCollectionLock.ps1] and copy it on your local SharePoint Server Drive.

Launch the script from a Windows Powershell Cmd Prompt using the following parametters:
.\SPSiteCollectionLock.ps1 -webappurl <URL> -lockstate [Unlock/ReadOnly]



Et voila !

11 comments:

genga g said...

I have picked cheery a lot of useful clothes outdated of this amazing blog. I’d love to return greater than and over again. Thanks! 
angularjs Training in online

angularjs Training in bangalore

angularjs Training in bangalore

angularjs Training in btm

genga g said...

Well somehow I got to read lots of articles on your blog. It’s amazing how interesting it is for me to visit you very often.
angularjs Training in online

angularjs Training in bangalore

angularjs Training in bangalore

angularjs Training in btm

Mounika said...

I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thx again!
Python training in marathahalli | Python training institute in pune

Mounika said...

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts
Python training in marathahalli | Python training institute in pune

simbu said...

I am really very happy to find this particular site. I just wanted to say thank you for this huge read!! I absolutely enjoying every petite bit of it and I have you bookmarked to test out new substance you post.
Java training in Chennai | Java training in Bangalore

Java interview questions and answers | Core Java interview questions and answers

Unknown said...

This is a good post. This post give truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. thank you so much. Keep up the good works.
Data Science Training in Indira nagar
Data Science training in marathahalli
Data Science Interview questions and answers

latchu kannan said...

very good to go through it
BEST ANGULAR JS TRAINING IN CHENNAI WITH PLACEMENT

https://www.acte.in/angular-js-training-in-chennai
https://www.acte.in/angular-js-training-in-annanagar
https://www.acte.in/angular-js-training-in-omr
https://www.acte.in/angular-js-training-in-porur
https://www.acte.in/angular-js-training-in-tambaram
https://www.acte.in/angular-js-training-in-velachery


nizam said...

I am really very happy by seeing your blog.
AngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery

lavanya said...

Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog. c Software Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery

aarthi said...

great information about locking system.Keep updating the blog.
Java training in Chennai

Java training in Bangalore

Java training in Hyderabad

Java Training in Coimbatore

Java Online Training

Anonymous said...

mmorpg oyunları
ınstagram takipci satın al
Tiktok Jeton Hilesi
tiktok jeton hilesi
sac ekim antalya
referans kimliği nedir
INSTAGRAM TAKİPCİ
İNSTAGRAM TAKİPÇİ SATIN AL
metin2 pvp serverlar

Post a Comment