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:

  1. Navigate to your SharePoint Online site, and Click on Settings Gear >> Click on the “Site Permissions” link.
  2. Click on the “Share Site” button on the Site Permissions pane.
    sharepoint online site owner powershell
  3. 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

The Full Control permission allows the user to manage all aspects of the site, including adding and removing users, managing content, and managing settings. Here is how to add a user to the site 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 = "https://crescent.sharepoint.com/Sites/warehouse"
$UserAccount = "Salaudeen@crescent.com"

#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
    $Ctx.Load($Web)
    $Ctx.Load($Web.AssociatedOwnerGroup)
    $Ctx.ExecuteQuery()
 
    #ensure the sharepoint online user
    $User=$web.EnsureUser($UserAccount)
  
    #sharepoint online powershell add user to owner group
    $Web.AssociatedOwnerGroup.Users.AddUser($User) | Out-null
    $Ctx.ExecuteQuery()
  
    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 a site owner with the PnP PowerShell as well. To grant site owner permissions using PowerShell, first, connect to the SharePoint Online site using the Connect-PnPOnline cmdlet. Once connected, the user can use the Add-PnPGroupMember cmdlet to assign permissions to a user.

#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Warehouse"
$UserAccount= "Steve@crescent.com"
 
#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 want to set up a Primary Admin (Sometimes called “Site Owner”), here is another post: How to Add Primary Site Admin in SharePoint Online?

How do I make someone a collection administrator in SharePoint Online?

If you need to make someone else a site collection admin, You can do so with the SharePoint Admin center, the “Site Collection Administrators” settings page of the site, or using PowerShell.
More info: Change Site collection administrator in SharePoint Online

How to create a custom permission level in SharePoint Online?

You can copy any existing permission levels, such as “Contribute”, and modify the new permission level by adding or removing permissions from it. E.g., You can create “Contribute without Delete” permission by removing “Delete” permissions from “Contribute”.
More info: Create custom permission in SharePoint Online

How do I give access to all authenticated users?

To share a SharePoint site with all internal users, grant access rights to the “Everyone except the external users” group.
More info: Grant permissions to all users in SharePoint Online

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!

One thought on “SharePoint Online: Grant Site Owner Permission to a User with PowerShell

  • I tried above URL but everytime I run permission level not found error occured
    Although i tried with Edit, Owner permission as well but still the same error

    Reply

Leave a Reply

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