Skip to content

Remove-SiteGroup

SharePoint Online: Removes a group from a site collection

#Requires -Version 5.1
#Requires -Modules Microsoft.Online.SharePoint.PowerShell

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$Site,
    [Parameter(Mandatory = $true)]
    [string]$Group
)

Process {
    try {
        $cmdArgs = @{ ErrorAction = 'Stop'; Site = $Site; Identity = $Group }
        Remove-SPOSiteGroup @cmdArgs | Out-Null
        [PSCustomObject]@{ Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"; Status = "Success"; Message = "Site group '$Group' removed from '$Site'" }
    }
    catch { throw }
}

URL of the site collection the group belongs to

Name of the group to remove

An interactive directory of PowerShell scripts.