SharePoint Online: Grant Site Owner Permission to a User with PowerShell

Requirement: Grant Site Owner Permissions to a User in SharePoint Online

How to Grant Site Owner Permissions to a User in SharePoint Online?

By adding people to the SharePoint Online site owners group, they can manage the site and perform typical site administration activities such as setting site branding and structure, adding or removing users, managing content, etc. To add a site owner to your SharePoint Online site, follow these steps:

  • Navigate to your SharePoint Online site, Click on Settings Gear >> and then click on the “Site Permissions” link
  • On the Site Permissions pane, click on the “Share Site” button.
    sharepoint online site owner powershell
  • Enter the user name in the search box and pick the user >> Select “Full Control” permission for the user and click on the “Add” button to grant the user site owner permissions.
    add site owner sharepoint online powershell

Alternatively, You can go to Site Settings >> Site Permissions >> Pick the relevant site owners group >> Click on “New” >> Add User to Group.

Add Site Owner in SharePoint Online using PowerShell

Here is how to add a user to the Owner group using PowerShell in SharePoint Online.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Variables for Processing
$SiteURL = ""
$UserAccount = "[email protected]"

#Setup Credentials to connect
$Cred = Get-Credential
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
    #Get the Default Owner Group of the site
    $Web = $Ctx.Web
    #ensure the sharepoint online user
    #sharepoint online powershell add user to owner group
    $Web.AssociatedOwnerGroup.Users.AddUser($User) | Out-null
    write-host  -f Green "User '$UserAccount' has been added to Owners Group of the Site!"
Catch {
    write-host -f Red "Error:" $_.Exception.Message

SharePoint Online: PnP PowerShell to Add Site Owner

We can add site owner with PnP PowerShell as well, as:

#Config Variables
$SiteURL = ""
$UserAccount= "[email protected]"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the Default Owners Group of the site
$OwnersGroup = Get-PnPGroup  -AssociatedOwnerGroup
#SharePoint Online pnp powershell to add site owner
Add-PnPGroupMember -LoginName $UserAccount -Identity $OwnersGroup

If you are looking to set a Primary Admin (Sometimes called as “Site Owner”), here is another post: How to Add Primary Site Admin in SharePoint Online?

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply