SharePoint site locked (read only)

Wed, Nov 22, 2017 3-minute read

Recently I was trying to figure out a way to restore a copy of a site collection to a different location. (Well that’s the short version, anyway, there was a much bigger issue I was trying to resolve.)

One solution was to backup the site collection and restore it to the new location. The site collection itself is a bit of a monster (around 300gb). From Central Administration I tried to use the GUI screen to backup the site collection to a network share.

This sat and span for ages on ‘Operation Initialising’ at which point I opted to cancel that and try Powershell.

Backup-SPSite -Identity http://mysite -Path “\share\file.bak”

This immediately sprang in to life (presumably because it doesn’t run inside the SP Timer Service.) I watched the file grow. Slowly. I mean really slowly. It’s only a test environment and the machine itself is a bit under-powered. So after it took an hour to export 15gb, I didn’t particularly feel like waiting the remaining 20 odd hours to let it complete and resolved to come up with a new plan. If you want to cancel a backup in Central Admin - you just click ‘Delete Backup Operation’. But in Powershell, there is no such option. A few CTRL + C’s later and still nothing, so I just closed the Powershell window.

Fast forward and I need to delete some libraries from my original site collection. I was trying Powershell:

$web = Get-SPWeb http://myweb<br /> $list = $web.Lists["My List"]<br /> $list.Recycle()<br /> $web.Dispose()<br />

This was erroring - “failed to delete list with 0 arguments”. Odd, I thought - I’ve done this hundreds of times before. Second guessing myself, I checked the documentation which confirmed there are no parameters for the Recycle or Delete methods.

Checking in the GUI, it appeared I didn’t have correct permissions. Yay! But hang on - I’m a Site Collection admin. Very odd. This is why you have to love SharePoint error messages.

And then it dawned on me - when you use Backup-SPSite, it will by default place a lock - essentially setting the site collection to read only - and since I didn’t exit the backup job cleanly, the lock remained in place.

From this page, you can then release the lock and all should be OK. But you can do it with Powershell as well, if you like:

`$site = Get-SPSite http://mysite
$site.WriteLocked ## True
$site.ReadOnly ## True

$site.WriteLocked = $false
$site.ReadOnly = $false
`

Strangely, there’s no ‘update’ method available or required. And following that, I can merrily delete everything willy nilly. Yay.