Set a Site Collection to Read Only via PowerShell

04/14/2010

PowerShell

If you need to set a site collection to read only, all you have to do is run two lines in PowerShell.

First, to verify the results, let’s look at the site when it is NOT read only:

As you can tell by the ribbon UI, you are able to select New Document, Upload Document, and New Folder. Now, let’s run the following from the SharePoint 2010 Management Shell:

$site = Get-SPSite -Identity <site url>
$site.readonly = $true

Refresh the page and notice how the previously available options are now grayed out:

Also notice that even the Add document link under the document has been removed, since you are no longer able to add documents in its read only state.

When you are ready to switch back, simply run the lines again with $false:

$site = Get-SPSite -Identity <site url>
$site.readonly = $false

Advertisements

Subscribe

Subscribe to our RSS feed and social profiles to receive updates.

2 Comments on “Set a Site Collection to Read Only via PowerShell”

  1. Mpumelelo Mthethwa Says:

    This Script is sweet, here i was thinking i will have to iterate throught each site and change all permissions to read.
    This has just saved me hours. Thanks Adam, u Rock

    Reply

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

%d bloggers like this: