Thursday, March 14, 2013

Remove All Users from SharePoint Group using PowerShell

Requirement: SharePoint Remove all users from group

SharePoint PowerShell to remove all users from 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 Exists!" -f yellow

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...