Sharepoint Site Collection –>check for No Access Site collections

Hi Readers,

I had been given a task to find the sites that are not accesible in our sharepoint enviornment.

I had just researched on the internet as I thought somebody might have written a script for this , so why to instill a duplicate effort.

Still I have put my effort to customize the script so that its becomes handy & can be used easily. 🙂

you just have to call the Lock status function at the end to any number of webapplications you have.

This will automatically traverse thru all sitecollections & provide the excel friendly output. (just drag the outout to excel)

——————————————————————————————————————————————————————

######################################################################
#    Author: Vikas Sukhija
#    Date:- 03/05/2013
#Description:- This script  will get the lock status of sharepoint sites
#Found on http://www.sharepointdiary.com/2012/12/check-lock-status-for-all-site.html
#Modification :- Changed code into function & made it more usable
######################################################################################

# Add Sharepoint Shell…

If ((Get-PSSnapin | where {$_.Name -match “Microsoft.SharePoint”}) -eq $null)
{
 Add-PSSnapin Microsoft.SharePoint.PowerShell
}
#Get All Site Collections of a web app

function Lockstatus ($webapp)

{

$Sites = Get-SPWebApplication $webapp | Get-SPSite -limit all | foreach {
#No Locks Applied?

if ($_.ReadOnly -eq $false -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $false)
 
{
$Result =”Unlocked”
}

#Read-only Lock?

elseif ($_.ReadOnly -eq $true -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $true)
 
{
$Result = “Read-Only”
}

#Adding Content Prevented?

elseif ($_.WriteLocked -eq $true -and $_.ReadLocked -eq $false -and $_.ReadOnly -eq $false) 
{
$Result = “Adding Content Prevented”
}

#No Access?

elseif ($_.ReadOnly -eq $null -and $_.ReadLocked -eq $null -and $_.WriteLocked -eq $null)
 
{
$Result=”No Access”
}
 
#Write the Result to CSV file separeted with Tab character
$save = $webapp + “_.txt”

$_.RootWeb.Title +”`t” + $_.URL + “`t” + $Result | Out-File $save -Append
 
}

}

#—————–Call function—————

Lockstatus SharePoint
Lockstatus “My Team”

##############################################################################

Regards

Sukhija Vikas

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s