Site Collection Administrators – SharePoint Online vs On-Premises

SharePoint Online

                Primary Site collection Admin

                                SPSite.Owner returns the Primary Site Collection Administrator. This is a single user property. Below is sample CSOM code:

$owner = $site.Owner



Write-Host $owner.LoginName

                Site collection Admins

In SPO, we are allowed to add multiple users as Site Collection Administrators. This can be done at SPO Admin Center UI or at the root site collection Site Settings > Site collection administrators page. You can even add groups as one of the Site collection administrators. There is no SecondaryContact property in SPO for the SPSite object. To validate that you can list out the properties on a SPSite object using below powershell:

foreach ($property in $site.PSObject.Properties) { $property.Name  }

To get a list of all site collection admins, we must use the IsSiteAdmin property per SPUser object. Below is PowerShell way of doing it:

                                                Get-SPOUser -Site $site.Url | FT LoginName, IsSiteAdmin -AutoSize

                                We can get the same result programmatically using CSOM. Below is sample line of code.

$users = $web.SiteUsers




$users | %{if($_.IsSiteAdmin -eq $True) {Write-Host $_.LoginName}}

 SharePoint On-Premises

                Primary Site collection admin

                                SPSite.Owner gets the primary admin.

                Secondary Site collection admin

                                SPSite.SecondaryContact gets the secondary admin.

You can also use the SPWeb.SiteAdministrators property to get all of the administrators for a given SPWeb. Use the RootWeb to get the admins for the site collection.


Comments (1)
  1. sreenivasulu reddy says:


    I Tried this command getting office 365 sites in getting all sites and site collection admin information i need please give me all sites url and site collection admin list and version please provide me ASAP

    i got below error

    Get-SPOUser : Cannot bind argument to parameter ‘Site’ because it is null.
    At line:1 char:19
    + Get-SPOUser -Site $site.Url | FT LoginName, IsSiteAdmin -AutoSize
    + ~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Get-SPOUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Online.SharePoint.PowerShell.Ge

    Get-SPOUser -Site $site.Url | FT LoginName, IsSiteAdmin -AutoSize

Comments are closed.

Skip to main content