kwizcom banner advertisement

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 site collection administrator in SharePoint 2010:
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 2010 using PowerShell:
In SharePoint 2010 onwards PowerShell cmdlets makes 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 "http://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 "http://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
Change Site Collection Primary, Secondary Administrators in SharePoint Change Site Collection Primary, Secondary Administrators in SharePoint Reviewed by Salaudeen Rajack on 2:25 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.