In provisioning solutions it can be a good practice to add a security group from Active Directory as an additional site collection owner. Unfortunately a security group is not accepted as either primary or secondary owner. So to set a group as site collection administrator, the easiest approach I could find was to set the “IsSiteAdmin” property on the User object.
# Configuration | |
$WebUrl = "http://teams.contoso.com/sites/team1" | |
$SiteAdminGroup = "CONTOSO\ContosoSiteAdmins" | |
# Set the AD group as site collection administrator | |
$Web = Get-SPWeb $WebUrl | |
$SiteAdminUser = $Web.EnsureUser($SiteAdminGroup) | |
$SiteAdminUser.IsSiteAdmin = $true | |
$SiteAdminUser.Update() |
How would you do this for SharePoint Online?
Setting “IsSiteAdmin” should also be available for SharePoint Online using CSOM: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.user.issiteadmin.aspx
This can be accomplished by connecting to SPO with PowerShell. My recommended approach would be to use the OfficeDev PnP PowerShell commands: https://github.com/OfficeDev/PnP-PowerShell
How would you do this for all site collection within a web/app? And how would you do this for all site collection in all web/applications?
Thank you!
@Rumi, you just have to get a list of all Site Collections and then iterate through all of them