How to add multiple site collection admins for a given site for secondary? I tried below but it replaces existing secondary. Any idea?
Set-SPSite –Identity $siteCollectionUrl –SecondaryOwnerAlias "domain\jdoe"
How to add multiple site collection admins for a given site for secondary? I tried below but it replaces existing secondary. Any idea?
Set-SPSite –Identity $siteCollectionUrl –SecondaryOwnerAlias "domain\jdoe"
If both primary and secondary owners are set, the only other way to add additional Site Collection admins is to use the New-SPUser command and include the switch parameter -SiteCollectionAdmin.
New-SPUser -UserAlias 'Contoso\Jdow' -DisplayName 'Jane Dow' -Web 'http://contoso.com' -SiteCOllectionAdmin
If you need more than two Site Collection admins for every Site Collection in a Web App, try the following.
$webApp = Get-SPWebApplication "http://mysite.sharepoint.com"
Foreach($site in $webApp.Sites)
{
New-SPUser -UserAlias "domain\user" -DisplayName "User Name" -Web $site.URL
$usr = Get-SPUser "domain\user" -Web $site.URL
$usr.IsSiteAdmin = $true
$usr.Update()
}
Eric's example worked in my Dev environment, but not my Test environment. The example I provided works in both.
The example could be cleaned up to validate the user and validate if they are already a site admin.
This would be easiest way with existing user for SharePoint Online:
$sites = gc sites.txt
foreach($site in $sites){set-spouser -Site $site -LoginName [email protected] -IsSiteCollectionAdmin $true}
This would be easiest way with existing user for SharePoint On-prem:
$sites = gc sites.txt
foreach($site in $sites)
{
set-spuser -Web $site -Identity 'domain\alias' -IsSiteCollectionAdmin $true
}