SP2010: Restoring MySite Site Administrators

Today we ran into a weird problem. People reported not having access to their personal documents library on their MySite. So I checked, the Personal Documents library ACL was empty for that particular user. But for other users, I noticed where were some entried, just not their own user account and always Limited rights (which means a document or folder inside the library probably has custom rights).

So what was happening? Well, I checked some more and noticed that all sites had an empty Site Administrators box (Site Settings -> Site Collection Administrators). Normally, the users account would be in there because you are always an administrator of your own personal MySite. Why those were cleared, I’m still not yet sure. But luckily, this is quite easily fixable with a short Powershell script. So I thought I’d share it here for anyone who might run across the same problem.

$wa = Get-SPWebApplication "https://www.sharepoint.com"

foreach ($site in $wa.Sites)
  if ($site.Url -match "https://www.sharepoint.com/mysite/") 
    Write-Host Updating $site.Url
    $user = $site.RootWeb.AllUsers[$site.Owner.UserLogin]
    $user.IsSiteAdmin = $true

Since the site.Owner property still points to the correct user, this script simply takes that user; finds it in the AllUsers collection, sets the IsSiteAdmin property to true and saves the changes. Et voila; all users can acess their libraries again.

, ,

Related posts

Latest posts

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *