How to Change Owner Specific Site Collection Administrator Using Powershell in SharePoint 2013

You may have a situation where you need to change owner-specific site collection administrators. For this you can get all site collections for that owner using the following PowerShell script. You can filter out sites that are of personal nature. Replace <userid> in the script below to your specific user id.
 
Get-SPSite -Limit All | ?{$_.url -notlike "*/my/*"} | ?{$_.Owner -like "*<userid>*"} | FT Url, Owner, SecondaryContact
 
 
It becomes very tedious to replace so that site owners use the user interface one by one. So what we can do is, use the following PowerShell command to replace all in one go.
 
Get-SPSite -Limit All | ?{$_.url -notlike "*/my/*"} | ?{$_.Owner -like "*<userid>*"} | %{Set-SPSite $_ -OwnerAlias "<domain\userid>"}
 
You need to replace <userid> and <domain\userid> appropriately. Run this command. For it to be successful, you need appropriate permission on the SharePoint box. There would be no messages if the command runs successfully, but error messages if there is any problem. You can rerun the first command with new user id to check that the replace command did its job.
 
 
 

Up Next
    Ebook Download
    View all
    Learn
    View all