Cant get siteowner for readonly sites

This is something I stumbled across recently… I wanted to retrieve a specific type of sites and their owners, when I checked the output of my script I figured that some sites seemed not to have siteowners, which irritated me a little. So I went to Central Admin checked the sites in the “View all sitecollections” area and found owners assigned to the sites. After fiddling around with PowerShell I figured out that if your site is set read-only you cant retrieve the siteowner anymore.

In the below PowerShell window you can see that I get a site and retrieve the owner from it. After that I set the site to be read-only, when I now retry to retrieve the owner I don’t get any information back. Once I set the read-only mode to false again the retrieval of the siteowner is working as expected.

I noticed this behavior in a SharePoint 2010 environment first and reproduced it in a SharePoint 2013 environment (from which I took the below screenshots).

image

If you look at the site in SharePoint 2013 you will be notified about the read-only status of your site.

image

In my special case I worked around it by retrieving the sitecollection administrators as I just needed somebody to contact but if you are really looking for that owner (or secondary owner) you might want to put a little bit more logic to your scripts to handle read-only sites.

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

%d bloggers like this: