Change Site Collection Primary, Secondary Administrators in SharePoint

Site collection administrators have god-like power within a SharePoint site collection, They can add/delete sites, content, users, etc for any site within a site collection. These administrators are responsible for administering their site collection and are recipients of any site status and resourcing Email notifications.

How to change the site collection administrator in SharePoint?

In SharePoint 2010 or 2013, primary, Secondary site collection administrators are set from Central Administration >> Application Management >> Change site collection administrators under Site Collection.

sharepoint 2010 change primary, secondary site collection administrator

Apart from these two site collection administrators, you can add additional administrators from: Site Settings >> Users And Permissions >> Site Collection Administrators .

How to change site collection administrator in SharePoint 2007 / SharePoint 2010 using STSADM?

To change primary site owner, secondary site owner in MOSS 2007, we use stsadm with siteowner switch.
stsadm -o siteowner -url https://my.crescent.com/personal/crescent_markh -ownerlogin domain\user -secondarylogin global\salaudeen

You can find site collection Primary and Secondary administrators under site collection administrators group (Site Actions >> Site Settings >> Site collection administrators) along with other site collection administrators. But Primary and Secondary Administrators are the only users who receive e-mail notifications for events, such as the quota reached, Site usage confirmation, etc.

Set site collection administrator in SharePoint programmatically:
To change primary administrator in SharePoint site with object model code C#:

String PrimaryOwner="Global\Salaudeen";
SPSite oSpSite = new SPSite(URL);
SPWeb oSPWeb = oSpSite.OpenWeb();
oSpSite.Owner = oSPWeb.EnsureUser(PrimaryOwner);
//oSpSite.SecondaryContact = oSPWeb.EnsureUser(SecondaryOwner);

This code sets SharePoint primary site collection administrator

Change site collection administrator in SharePoint using PowerShell:

From SharePoint 2010 onwards PowerShell cmdlets make it much simpler! To get Primary and Secondary Site Collection Administrators:

Get-SPSite -Limit all | Select URL, Owner, SecondaryContact | Out-Gridview

Similarly, to set Site collection Primary and secondary owners, we can use the powershell cmdlet: Set-SPSite

Set-SpSite "https://sharepoint.crescent.com" -owneralias "domain\user" -SecondaryOwnerAlias "<domain\user>"

Change site collection administrators for all site collections
We can just pipe them together to set site collection primary and secondary administrators for all sites in a web application

Get-SPWebApplication "https://intranet.crescent.com" | Get-SPSite -Limit All | ForEach-Object { Set-SPSite $_ -OwnerAlias "<domain\user>" -SecondaryOwnerAlias "<domain\user>" }

This will change SharePoint 2010 primary site collection administrator and secondary site collection administrator. Related Post: Add Site Collection Administrators Programmatically in SharePoint

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

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