SharePoint Online: How to Change the Site Owner (Primary Admin) using PowerShell?

Requirement: Change the Site Owner in SharePoint Online using PowerShell.

How to Change the Site Owner in SharePoint Online?

As teams and projects evolve in any organization, it becomes necessary to officially transfer ownership of SharePoint Online sites and associated permissions to new users. Whether due to organizational restructuring, role changes, or simply part of routine maintenance, the ability to seamlessly change the site owner in SharePoint Online is essential for administrators and IT professionals.

In this blog post, we will show you how to change the primary site owner in the SharePoint site. We will walk you through the process step by step and show you how to change the site owner in SharePoint Online using PowerShell. Let’s get started!

How do I change ownership of a SharePoint Online site? Site Owners of a SharePoint Online site collection can be changed through SharePoint Online Admin Center or PowerShell. As a side note, To change the ownership of a SharePoint Online site, you must have site admin permissions in Microsoft 365.

To change site owner in SharePoint Online, follow these steps:

Important: You must be either Global Administrator or SharePoint Online Administrator to change site owners in SharePoint Online!
  1. Sign in to Office 365 Admin Center (https://portal.office.com/), and click on the “SharePoint Admin Center” link from the “Admin Centers” section. 
  2. You’ll be landing in the Site Collections list in the SharePoint Admin center (https://YourDomain-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx) with all site collections listed. 
  3. Select the site collection from the list of site collections to which you want to change the site owner >> From the ribbon, click on “Permissions” and then “Manage Admins”.
  4. On the “Manage Administrators” panel, You can change the primary site collection administrator – Site owner by setting them as “Primary Admin”. You can also configure additional site collection administrators.
  5. Enter the name of the primary site collection administrator and Click on the Save button once you are done with your changes.
    change site owner sharepoint online powershell

You can add only ONE site owner (Primary Site Collection Admin) in SharePoint Online! SharePoint Online has no secondary admin, but you can add more than one “Site collection Administrator” and grant them site permissions through SharePoint site settings.

Now, let’s see how to change the site owner in SharePoint Online using PowerShell.

Change SharePoint Site Owner using PowerShell

We can change the site owner using the Set-SPOSite cmdlet. Here is an example: Set the variables according to your environment.

#Variables
$AdminCenterURL = "https://Crescent-admin.sharepoint.com"
$SiteCollURL="https://Crescent.sharepoint.com/Sites/marketing"
$SiteOwner = "Peter@crescent.com"
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)
 
#sharepoint online powershell set site owner
Set-SPOSite -Identity $SiteCollURL -Owner $SiteOwner -NoWait

Please note, You should use this only for Non-Group connected sites. If you execute this script on a Microsoft 365 group-connected site, It will set the given user as the site owner and remove the existing Office 365 group from the Site owner permissions.

Change Site Owner for All Non-Group Connected Sites in the Tenant

Make sure you set the parameters according to your environment and run the script. This cmdlet prompts you for credentials. Enter the Administrator’s credentials.

#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
$SiteOwner= "Steve@crescent.com"

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)

#Get All site collections - Excluding certain templates and Group sites
$SiteCollections = Get-SPOSite -Limit All | Where { $_.Template -NotIn ("SRCHCEN#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1","GROUP#0")}

#Loop through each site collection
ForEach($Site in $SiteCollections)
{
   #sharepoint online powershell change site owner
   Set-SPOSite -Identity $Site.url -Owner $SiteOwner
   Write-host "Added Site Owner to "$Site.Url
}

This script updates the SharePoint Online Site Owner for all site collections – excluding group sites and specific sites like Search Center, app catalog, etc.

This article talks about adding a primary admin AKA primary site owner to a SharePoint Online site. In case, You are looking for adding someone to the Site Owner’s group (similar to site members, site visitor) with ‘Full control’ permissions, use: How to Grant Site Owner Permissions to a User in SharePoint Online using PowerShell?

PnP PowerShell to Set Site Owner in SharePoint Online

Use this PnP PowerShell script to set the site owner for a SharePoint Online site.

#Parameters
$AdminCenterURL ="https://crescent-admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites/purchase"
$SiteOwner = "Steve@crescent.com"

#Connect to Admnin Center
Connect-PnPOnline -Url $AdminCenterURL -UseWebLogin

#Get the Site
$Site  = Get-PnPTenantSite -Url $SiteURL

#Update the Site Owner
$Site.Owner = $SiteOwner
$Site.Update()
Invoke-PnPQuery

Managing Site Owner for Microsoft 365 Group-Connected Sites

In Microsoft 365 group-connected sites, the site owner is set to Group owner by default. So, to add a group owner, You have to add the user as the group’s owner from the Admin Center.

  1. Login to SharePoint Admin Center >> Select the group site.
  2. Click on “Permissions” from the toolbar >> Manage Group Owners.
  3. Add a new user to the Owner list of the Group.
    add group owner for sharepoint online site

You can also add-remove the group members using Microsoft 365 admin center.

PnP PowerShell to Add Owner to the Associated Microsoft 365 Group

As the Group connected site’s permissions are controlled at the Microsoft 365 group level, We have to add an owner at the group level! Here is how:

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/CorporateBranding"
$SiteOwner= "Salaudeen@crescent.com"

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive

    #Get the Site
    $Site = Get-PnPSite -Includes GroupId
     
    #Add Owner to Microsoft 365 Group connected to the site
    Add-PnPMicrosoft365GroupOwner -Identity $Site.GroupId -Users $SiteOwner
    Write-host "`tAdded Owner to the Associated Microsoft 365 Group!" -f Green    
}
Catch {
    write-host -f Red "`tError:" $_.Exception.Message
}

To add a group owner to all Microsoft 365 group-connected sites, use the following:

#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
$SiteOwner= "Salaudeen@crescent.com"

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $AdminCenterURL -Interactive
 
    #Get all Microsoft 365 Group connected Sites
    $Sites = Get-PnPTenantSite | Where { $_.Template -like 'GROUP*'}

    #Iterate through sites and set site owner
    ForEach($Site in $Sites) 
    { 
        #Add Owner to Microsoft 365 Group connected to the site
        Add-PnPMicrosoft365GroupOwner -Identity $Site.GroupId -Users $SiteOwner
        Write-host -f Green "Added Owner to the Associated Microsoft 365 Group for "$Site.url
    }
}
Catch {
    write-host -f Red "`tError:" $_.Exception.Message
}

Here is another post on adding users to the SharePoint Online site collection administrators group: PowerShell to Add Site Collection Administrators in SharePoint Online

Wrapping up

In summary, changing the primary owner of a SharePoint Online site is a common administrative requirement as teams and project responsibilities shift within an organization. We’ve explored several methods to change the site owner, from using the SharePoint admin center to employing PowerShell commands for more granular control. Each method has its place, depending on the operation’s scale and your organization’s specific needs.

For administrators managing a handful of sites, the SharePoint admin center offers a user-friendly interface for quick changes. Meanwhile, PowerShell scripts cater to those requiring bulk operations or automation, providing a powerful toolset for managing site ownership across numerous sites efficiently. Whether you need to update site ownership due to employee departures, reassignments, or simply granting site steward responsibilities to new individuals, this guide should provide the essential instructions needed.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

9 thoughts on “SharePoint Online: How to Change the Site Owner (Primary Admin) using PowerShell?

  • Hello, first time commentor, long time reader. Do you know if there is a PNP equivelant of Set-SPOSite -Identity $SiteCollURL -Owner $SiteOwner ?

    I’ve tried the following but apparently it is a read only property. Surely there is an answer here… Maybe not?

    $site = Get-pnptenantsite -url “siteurlhere”
    $Site.Owner = “NewOwner”
    $Site.Update()

    Reply
    • Hi Nick,
      Post has been updated with the PnP PowerShell script to set site owner. Make sure you have SharePoint Online Admin permissions and installed the PnP.Powershell module.

      Reply
      • Im getting the same error as Nick that when doing $Site.Owner = $SiteOwner it errors InvalidOperation: ‘Owner’ is a ReadOnly property.
        Our sharepoint sites use the classic mode so dont have 365 groups assigned to them so adding the owner a group level is out.
        Any suggestions?
        I have Admin permissions and the latest PnP.Powershell module installed

        Reply
        • Workaround i found to use PNP and set primary owner was:
          Create the site with New-PnPTenantSite with whatever user you want
          Then add the group you want to be the primary owners by running
          Set-PnPTenantSite -Identity $URL -Owners “Group Name”
          Then remove all the other users with
          Get-PnPUser | ? Title -ne “Group Name” | Remove-PnPSiteCollectionAdmin

          Reply
  • Your PnP POSH example didn’t work for me, getting error “Failed to add user admins to site collection admins – ‘Owner’ is a ReadOnly
    property.”. Looking into PnP POSH Github, looks like the Owner property only has a getter, so this seems accurate.

    Reply
      • Unfortunately it can’t. I am also getting “‘Owner’ is a ReadOnly property” error

        Reply
  • Do you have PowerShell for changing site owner of on-prem sharepoint server?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *