SharePoint Online: Change Group Owner using PowerShell

SharePoint groups simplify permission administration by assigning a set of users to a group and assigning permissions to them through the group. When we create a site, The default Owner group of the site (E.g., on the “Marketing” site, its “Marketing Owners”) is assigned as Group owner for all groups. If anyone creates a custom group, the creator will be designated as the group owner.

How to Change the Group Owner in SharePoint Online?

If you are the admin of a SharePoint Online site and need to change the group owner, there are a few steps you’ll need to take. In this blog post, we will walk you through the process of changing the group owner in SharePoint Online. This can be a useful process if you need to transfer ownership of a group to another user.

Follow these steps to change the owner of a group in SharePoint Online:

  1. Go to Site Settings >>  Site Permissions >> People and Groups.
  2. Pick the group you want to change the group owner from the left navigation.
  3. From the group page, Click on Settings >> Group Settings.
  4. Enter the new group owner in the “Group Owner” field. Hit OK to save your changes. This changes the owner of a SharePoint Online group.
    sharepoint online change group owner powershell

Set Group Owner using SharePoint Online Management Shell:

You can use SharePoint Online Management Shell to set the owner of a SharePoint Online group.

#Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com"
$GroupName="Team Site Members"
$OwnerName="Salaudeen@crescent.com"
 
#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential $Cred

#sharepoint online change group owner powershell
Set-SPOSiteGroup -Site $SiteURL -Identity $GroupName -Owner $OwnerName 

PowerShell to Change Group Owner in SharePoint Online: 

Here is how to set SharePoint Online group owner using PowerShell CSOM.

#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"
   
#Config Parameters
$SiteURL= "https://crescent.sharepoint.com"
$GroupName="Team Site Members"
$GroupOwnerName="Salaudeen@crescent.com"
#$GroupOwnerName="Team Site Owners"

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
   
    #Get the Group owner - Can be an another Group or User Account
    #$GroupOwner = $Ctx.Web.SiteGroups.GetByName($GroupOwnerName)
    $GroupOwner = $Ctx.Web.EnsureUser($GroupOwnerName)
    
    #Get the Group
    $Group = $Ctx.Web.SiteGroups.GetByName($GroupName)

    #Set the Group Owner
    $Group.Owner = $GroupOwner
    $Group.Update()
    $Ctx.ExecuteQuery()

    Write-host -f Green "Group Owner has been Updated!"
}
Catch {
    write-host -f Red "Error changing Group Owner!" $_.Exception.Message
}

PowerShell to Change Group Owner for All Groups in SharePoint Online:

Let’s change the group owner for all groups in the SharePoint Online site collection.

#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"
   
#Config Parameters
$SiteURL= "https://crescent.sharepoint.com"
$GroupOwnerName="Team Site Owners"

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
   
    #Get the Group owner - Can be an another Group or User Account
    $GroupOwner = $Ctx.Web.SiteGroups.GetByName($GroupOwnerName)
    
    #Get All Groups of the Site
    $GroupsColl = $Ctx.web.SiteGroups
    $Ctx.Load($GroupsColl)
    $Ctx.ExecuteQuery()

    #Iterate through each Group - Exclude SharePoint Online System Groups!
    ForEach($Group in $GroupsColl | Where {$_.OwnerTitle -ne "System Account"})
    {
        Write-Host -f Yellow "Changing the Owner of the Group:", $Group.Title

        #sharepoint online powershell set group owner
        $Group.Owner = $GroupOwner
        $Group.Update()
        $Ctx.ExecuteQuery()
    }    

    Write-host -f Green "All Group Owners are Updated!"
}
Catch {
    write-host -f Red "Error changing Group Owners!" $_.Exception.Message
}

Here is another post for SharePoint On-premises: How to Change the Group Owner in SharePoint using PowerShell?

SharePoint Online: Change Group Owner using PnP PowerShell

To set the group owner for a SharePoint Online group, use this PnP PowerShell cmdlet Set-PnPGroup:

#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/Sales"
$GroupName="Sales Portal Members"

#Group owner variable: Can be existing group or user account Email
$GroupOwner = "Sales Portal Owners" #or Salaudeen@Crescent.com
 
#Connect PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Set Group Owner
Set-PnPGroup -Identity $GroupName -Owner $GroupOwner

To change the site owner in SharePoint Online, use: How to Change SharePoint Online Site Owner using PowerShell?

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

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