SharePoint Online: How to Change Site Owner using PowerShell?

Requirement: Change Site Owner in SharePoint Online using PowerShell

How to Change Site Owner in SharePoint Online?
Site Owners of a SharePoint Online site collections can be changed only through SharePoint Online Admin Center or PowerShell. 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!
  • Sign in to Office 365 Admin Center (https://portal.office.com/), Click on "SharePoint Admin Center" link from "Admin Centers" section. 
  • You'll be landing to Site Collections list in SharePoint Admin center (https://YourDomain-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx) with all site collections listed. 
  • Select the site collection from the list of site collections to which you want to change the site owner >> From the ribbon, Click on "Owners" and then "Manage Administrators"
  • On the "Manage Administrators" dialog box, You can change the primary site collection administrator - Site owner. You can also configure additional site collection administrators. Enter the name for primary site collection administrator and Click OK save your changes.
    change site owner sharepoint online powershell
You can add only ONE site owner (Primary Site Collection Admin) in SharePoint Online! There is no secondary admin in SharePoint Online, but you can add more than one "Site collection Administrators". Now, let's see how to change site owner in SharePoint Online using PowerShell.

Change Site Owner SharePoint Online using PowerShell
We can change the site owner using Set-SPOSite cmdlet. Here is an example: Set the variables according to your environment.
#Variables
$AdminCenterURL = "https://crescenttech-admin.sharepoint.com"
$SiteCollURL="https://crescenttech.sharepoint.com/Sites/marketing"
$SiteOwner = "Peter@TheCrescentTech.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

Change Site Owner for All Site Collections in the Tenant:
Make sure you set the parameters according to your environment and run the script:
Step 1: Connect to SharePoint Online
#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
$SiteOwner = "Salaudeen@crescent.com"

#Connect to Tenant Admin
Connect-SPOService -Url $AdminCenterURL
This cmdlet prompts you for credentials. Enter the Administrator's credentials.

Step 2: Update Site Owner for all site collections
#Get all site collections 
$SiteCollections = Get-SPOSite -Limit ALL -includepersonalsite $False

#Loop through each site collection
ForEach($Site in $SiteCollections)
{
 #change Site Owner
 Set-SPOSite -Identity $Site.url -Owner $SiteOwner
}
You can verify the site owners with cmdlet:
Get-SPOSite | Select url, owner

Here is my another post on adding site collection administrators to SharePoint Online: PowerShell to Add Site Collection Administrators in SharePoint Online
SharePoint Online: How to Change Site Owner using PowerShell? SharePoint Online: How to Change Site Owner using PowerShell? Reviewed by Salaudeen Rajack on February 07, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.