Remove All Users from a SharePoint Group using PowerShell

Requirement: Remove all users from a group in SharePoint

SharePoint PowerShell to remove all users from a group:

PowerShell script to remove all user from a SharePoint group programmatically:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Site collection URL 
$GroupName = "Operation Managers"

#get the Root Web
$web = Get-SPWeb $SiteUrl

#Get the Group
$Group = $Web.sitegroups | Where-Object {$_.Name -eq $GroupName}

If($Group -ne $null)
    $GroupUsers = $Group.Users
    foreach ($User in $GroupUsers)
        #powershell to remove all users from sharepoint group
        write-host "Removed User from Group:" $User
    write-host "Group doesn't Exist!" -f yellow

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!

Leave a Reply

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