Change site collection administrators using PowerShell

In a minute, I will show you how to change the site collection administrators for all site collections using PowerShell. Thanks to Maarten Peeters for helping!

But first, it may be easy to get a result for all the current site collection administators, in case you want to roll back:

Get-SPSite -Limit all | FT Url, Owner, SecondaryContact -AutoWidth

Site collection administrators

Now if you want to change all site collection administrators and secondary site collection administrators (As you would set in Central Administration)

Get-SPSite -Limit All | %{Set-SPSite $_ -OwnerAlias "<domainuser>" -SecondaryOwnerAlias "<domainuser>"}

If you are using MySites and personal sites have been created, you might want to use the following, to exclude the MySite site collections. Please check if you are using the “personal” managed path. If you are using a different managed path, you can change the “*/personal/*” to reflect your environment.

Get-SPSite -Limit All | ?{$_.url -notlike "*/personal/*"} | %{Set-SPSite $_ -OwnerAlias "<domainuser>" -SecondaryOwnerAlias "<domainuser>"}

I hope this helps someone out there to save some valuable time!

One thought on “Change site collection administrators using PowerShell

  1. thanks for sharing.
    may i know is it possible for us to change the SharePoint site primary owner to another person, for a given primary site owner?
    forgot to mention, in case of the primary site owner have more than 100 SharePoint sites which the ownership needs to be transferred to another person.

Leave a Reply

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