Saturday, August 1, 2015

SharePoint Online: Add Site Collection Administrator using PowerShell

SharePoint site collection administrators have Full access rights to manage all sites under a site collection. When creating a site collection, Global Administrator or SharePoint Online Administrator will automatically become the primary site collection admin. A SharePoint online site collection can have several administrators, but only one primary administrator, unlike SharePoint on-premises.

Its possible to add multiple site collection admins for any SharePoint site collection. To add additional site collection administrator in SharePoint online, you must be either Global Administrator or SharePoint online Site Collection Administrator of the particular site collection.

SharePoint online add site collection administrator

  • Navigate to your SharePoint Online administration center (E.g. https://crescent-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx )
  • Select the site collection, Click on "Owners" button from the ribbon and then click on "Manage Administrators" menu item.
  • This brings "Manage Administrators" page where you can add multiple site collection administrators. Also provides the option to change primary site collection administrator.
  • Now you can add new admins into the Site Collection Administrators box.
  • Once you have added the new user press OK to save the changes and any new Site Collection Administrator will have full rights to every site and sub-site within that Site Collection
Alternatively, Once the site collection is created, You can also navigate to Site Settings >> Site collection administrators link to add additional site collection administrators.

Quite easy, isn't it? Well, Its easy for one single site collection. However there is a problem when you have large number of site collections. Say, you have 100's of SharePoint online site collections, You can't simply select all of your site collections and add a site collection administrator to all of them at one shot!

In SharePoint Online, site collection administrators to be added on a site collection by site collection basis, as there is no web application level users policies can be set from Central Administration as we do in SharePoint on-premises.

So, the solution is: Using PowerShell to add site collection administrator in SharePoint online!

PowerShell Script to Add Site Collection Administrator in SharePoint Online:
#Variables for processing
$AdminURL = "https://crescent-admin.sharepoint.com/"
$AdminName = "salaudeen@crescent.onmicrosoft.com"
$SiteCollURL = "https://crescent.sharepoint.com/sites/Sales/"
$SiteCollectionAdmin = "mark@crescent.onmicrosoft.com"

#User Names Password to connect 
#$SecurePWD = read-host -assecurestring "Enter Password for $AdminName" 
$SecurePWD = ConvertTo-SecureString "Password1" –asplaintext –force  
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $SecurePWD
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminURL -credential $Credential

#Add Site collection Admin
Set-SPOUser -site $SiteCollURL -LoginName $SiteCollectionAdmin -IsSiteCollectionAdmin $True

To Add Site collection Admin to All SharePoint Online Sites, use:
#Get All Sites collections
$Sites = Get-SPOSite
Foreach ($Site in $Sites)
{
    Write-host "Adding Site Collection Admin for:"$Site.URL
    Set-SPOUser -site $SiteCollURL -LoginName $SiteCollectionAdmin -IsSiteCollectionAdmin $True
}
Change Primary Site Collection Administrator using PowerShell:
#Variables for processing
$AdminURL = "https://crescent-admin.sharepoint.com/"
$AdminName = "salaudeen@crescent.onmicrosoft.com"
$SiteCollURL = "https://crescent.sharepoint.com/sites/Sales"
$NewSiteAdmin = "mark@crescent.onmicrosoft.com"

#User Names Password to connect 
$SecurePWD = ConvertTo-SecureString "Password1" –asplaintext –force  
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $SecurePWD
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminURL -credential $Credential

#Change Site Collection Primary Admin
Set-SPOSite -Identity $SiteCollURL -Owner $NewSiteAdmin -NoWait

Related Articles:



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

1 comment :

  1. Note: Get-SPOSite does not return sites created by O365 Groups (& Planner) or Teams, unless you specifically specify the URL of the site... so no enumeration of those sites :(

    ReplyDelete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...