Showing posts with label powershell remove user. Show all posts
Showing posts with label powershell remove user. Show all posts

02 September, 2013

Remove/Delete user from all SharePoint groups in the web application/site collection – SharePoint 2010

This is one of the requirement in which one of our admin changed the project so it means he will no longer be a part of any SharePoint site collection or any web application.

By considering this requirement, we need to remove this specific users across all site collections, all groups, all web applications…


Here is the script for the same:

$URL="https://Sharepoint2010SiteURL"
$site =Get-SPSite($URL)
$web = $site.OpenWeb()
$groups = $web.sitegroups
$user = $web .AllUsers.Item("name of user")
foreach ($spgroup in $groups)
{
   $spgroup.RemoveUser($user)
   $spgroup.Updae()
}

If you have any queries/questions regarding the above mentioned information then please let me know, Thank you.