SharePoint (2003 thru Online): February 2023

Monday, February 13, 2023

Adding or updating the Primary admin for any SPO Site Collection thru PowerShell Commands.

In this post, we want to achieve the ability of adding or updating the Primary admin for any Site Collection thru PowerShell Commands.

With the new features in SharePoint Admin center, we lost the ability to change the Primary Admin for any Site Collection thru 'Permissions' feature. With new 'Membership' feature, we can add Site admins, Site Owners, Site Members and Site Visitors, but cannot add or update any Site admin(s) as Primary Admin.



With the below PowerShell Commands are updating the Primary Admin from Venugopal Reddy (gvr@gurram.onmicrosoft.com) to Mahin Gurram (gmr@gurram.onmicrosoft.com)

#Variables
$SiteCollURL = "https://gurram.sharepoint.com/sites/smb"
$SiteOwner = "gmr@gurram.onmicrosoft.com"

#Connect to SharePoint Online
Connect-SPOService
#The above Command will prompt you enter SharePoint Admin URL & dialog box to enter your SharePoint Admin Credentials

#Sharepoint online powershell Set Site Owner (Primary Admin) - with Variables
Set-SPOSite -Identity $SiteCollURL -Owner $SiteOwner -NoWait

#Sharepoint online powershell Set Site Owner (Primary Admin) - Direct Command
Set-SPOSite -Identity https://gurram.sharepoint.com/sites/smb -Owner gmr@gurram.onmicrosoft.com -NoWait

After running the above Commands, below is the PowerShell Screen.


The required Site Collection's Primary Admin was updated.