How To: Make your SharePoint 2010 site collection read-only, restrict delete

SharePoint 2010 allows administrators to set certain site collections to read only or restrict delete. This is done on a centralized site collection level and has nothing to do with permission assignments on your lists and libraries.

SharePoint 2010 allows administrators to set certain site collections to read only or restrict delete. This is done on a centralized site collection level and has nothing to do with permission assignments on your lists and libraries.

Here is a scenario:
a project represented by a site collection in SharePoint has completed and all of the deliverables must be read only, or new content must not be added only existing ones modified.

Let`s take a look how you can implement such a lock using PowerShell. Also, for more PowerShell hands on scenarios check out my new book.

From within SharePoint 2010 Management Shell execute the following command to prevent users from adding, updating, or deleting content, basically a read-only site collection:

1
Set-SPSite -Identity "http://myserver/sites/site1" -LockState "ReadOnly"

Now, when you access a list item for example and try to edit it – the controls will be grayed out. The same goes for when you try adding new item – you’ll get an error right on the new item form.

2011-12-08-SP2010CollectionReadOnly-01.png

2011-12-08-SP2010CollectionReadOnly-02.png

To make the site collection accessible again call:

1
Set-SPSite -Identity "http://myserver/sites/site1" -LockState "Unlock"

For the scenario where no new content can be added but existing content modified and deleted, here is the command:

1
Set-SPSite -Identity "http://myserver/sites/site1" -LockState "NoAdditions"

When users try to add new content, the form will still show but the following error will occur when saving the new item:

0x81020066
Additions to this Web site have been blocked.
Please contact the administrator to resolve this problem.

2011-12-08-SP2010CollectionReadOnly-03.png

Lastly, to prevent access to the site use the following command:

1
Set-SPSite -Identity "http://myserver/sites/site1" -LockState "NoAccess"

Resulting in the following error when site collection is accessed:

0x81020071
Access to this Web site has been blocked.
Please contact the administrator to resolve this problem.

2011-12-08-SP2010CollectionReadOnly-04.png

To unlock any of the above locks, use the Unlock command above.

Advertisements