Requirement

Remove all users from a SharePoint site, including all entries in the User Information List which can be located at:

http://sitecollection/_catalogs/users/detail.aspx

Solution


#This script will delete all users in the User Information List. Change $url to your site/site collection.

$url = “http://sitecollection”
$web = get-spweb $url
$list = $web.Lists[“User Information List”]
$listItems = $list.Items
$listItemsTotal = $listItems.Count
for ($x=$listItemsTotal-1;$x -ge 0; $x–)
{
Write-Host(“DELETED: ” + $listItems[$x].name)
remove-spuser $listItems[$x][“Account”] -web $url -confirm:$false
}
$web.dispose()