SharePoint Online: Delete Group using PowerShell

Requirement: SharePoint Online Delete Group using PowerShell

How to Delete a SharePoint Online Group?

If you’re looking for a quick and easy way to delete a group in SharePoint Online, this article is for you. In just a few steps, you can remove a group from your site with the web browser. We’ll also take a look at how to delete a group in SharePoint Online using PowerShell!

Here is how to remove a user group in SharePoint Online:

  • Login to your SharePoint Online site >> Click on Settings gear >> Click Site Settings.
  • On the Site Settings page, click on “People and groups” under the “Users and Permissions” section.
  • Click on the Group Name from the left navigation. You may need to click on “More” and then select the group
    sharepoint online powershell delete group
  • On the group page, click on Settings >> Group Settings
  • On the group settings page, scroll down and click on the “Delete” button and confirm the prompt, click OK to remove the group in SharePoint Online.
    sharepoint online delete group powershell

This deletes the user group in SharePoint Online.

Have you ever needed to delete a group in SharePoint Online, but didn’t want to go through the hassle of navigating the web interface? Sure, let’s delete a SharePoint Online group using PowerShell!

Removing a group from a site also removes the users within that group from the site.

Delete SharePoint Online Group using Remove-SPOSiteGroup PowerShell cmdlet

The Remove-SPOSiteGroup cmdlet lets you delete an existing SharePoint group from the SharePoint Online site collection. It requires you to pass the URL of the site collection, the name of the group to delete. E.g. To delete the security group that you created in the previous step, you could run the following line of PowerShell:

#Variables for Admin Center & Site Collection URL
$AdminCenterURL = ""
$SiteURL = ""

#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)

#sharepoint online delete group powershell
Remove-SPOSiteGroup -Site "" -Identity "Marketing Managers"

This Remove-SPOSiteGroup cmdlet removes a SharePoint Online group from a site collection.

SharePoint Online: Delete Group using PowerShell

Here is the PowerShell to delete group in SharePoint Online using PowerShell:

#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"

#Function to remove a group from site
Function Remove-SPOGroup([String]$SiteURL, [String]$GroupName)
    Try {
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        #Get the Group by name

        #Remove group from the web

        #Execute the query
        write-host -f Green "Group '$GroupName' Deleted Successfully!" $_.Exception.Message
    Catch {
        write-host -f Red "Error Removing Group!" $_.Exception.Message
#Config Parameters
$GroupName="Project Managers"

#Call the function - powershell commands to delete sharepoint online groups
Remove-SPOGroup -SiteURL $SiteURL -GroupName $GroupName

This PowerShell deletes the given group in SharePoint Online.

Delete SharePoint Online Group using PnP PowerShell

Let’s delete a SharePoint Online group using PowerShell cmdlet Remove-PnPGroup.

#Config Variables
$SiteURL = ""
$GroupName ="Contributors"

#Get Credentials to connect
$Cred = Get-Credential

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
#Delete a Group from site
Remove-PnPGroup -Identity $GroupName -Force

This can be helpful if you need to delete a group that has been created by mistake, or if you no longer need the group and want to remove it from your site.

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 *