Remove users from User Information List (people picker) using PowerShell

This post will describe how you can remove users in bulk from the User Information List using a PowerShell script and a simple CSV file.

In SharePoint 2010, the people picker retrieves data from multiple sources.

– The Site Collection’s User Information List (UIL);
– Active Directory.

When you delete a user from Active Directory, this will not mean the user isn’t searchable in SharePoint. Actually, if you look for this person in the people picker, you will probably find him/her. As the data is pulled from different sources, there may be several causes for this.

Assuming the user is really deleted from the Active Directory, I will give you some pointers as to how to “delete” the users from the People picker.

I have a user called Kim Akers in my Contoso environment. She has permissions on several sites/subsites, and placed documents and list items in multiple places.

Example site

She also has a MySite.


For some reason, Kim is fired. The Active Directory administrators remove her account from Active Directory.

However, when I look at the People Picker in SharePoint, I can still find this user.

People picker

Why is this happening?

Every user that is given direct permissions, or has logged in to SharePoint, will be added to the Site Collection’s User Information List. This is a hidden list, that you can access by going to your site collection’s URL and add /_catalogs/users/simple.aspx. For instance:

This will show a list of all users that have logged in on your SharePoint. Sure enough, Kim can still be found here, even though her account has been deleted in Active Directory.

User Information List


To remove the user from the information list, you can use the GUI. If you want more information on how to do this, read this article. Also, make sure the profile for this user is not in the Profile Database. You can remove users from the Profile Database directly by going to Central Administration -&> Application Management -&> Manage Service Application -&> Click your User Profile Service Application -&> Manage User Profiles -> Find profile by entering the name -> Select the name in the list, and click Delete.

In my case, I wanted to remove a list of users from All site collections, because I am certain that these users will never log in again, and I don’t want them to show in the people picker. The below script will do just that!

[Parameter(Mandatory=$true)][ValidateScript({Test-Path $_ -Include "*.csv"})]

#This script will remove users specified in the CSV.

$CSVFile = Import-CSV $CSVPath
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

#Get all site collections
$Sites = Get-SPSite -Limit All
$AllSites = @()
foreach($Line in $CSVFile)
foreach($Site in $Sites)
#Get the rootweb for the site collection
$RootWeb = $Site.RootWeb
If([bool](Get-SPUser $Line.Username -Web $RootWeb -EA SilentlyContinue) -eq $True)
#Remove the user from the User Information List
Remove-SPUser -Identity $Line.username -Web $RootWeb -Confirm:$False
$AllSites += $RootWeb.Url
if(!($AllSites).count -eq 0)
#Give feedback on deleted users
Write-Host "Removed user $($Line.username) from:" -Fore "Magenta"
foreach($S in $AllSites){Write-Host "- $S"}
Write-Host ""
$AllSites = @()

I save the above text in a .ps1 file called Remove-SPUserBulk.ps1.

Next, I create a CSV file (Users.csv) that will contain all the users that I want to remove. My demo CSV looks like this:


As you can see, I added a non-existing account, to show that the script actually just deletes the existing user, and the output is correct. I run the script by going to the location where the Remove-SPUserBulk.ps1 file is located, and enter: “Remove-SPUSerBulk.ps1 -CSVPath “C:scriptsUsers.csv”.

Below is the result.


Be aware that if the user is a site collection administrator, you will get an error stating you cannot delete the owners of a Web site collection.

12 thoughts on “Remove users from User Information List (people picker) using PowerShell

  • What if you have the opposite situation and you have an AD account disabled and the person is no longer showing up in the people picker column in SharePoint, what happens to your list items that already have that person listed in them? Will those items not be editable anymore, as it won’t let you save? Or what about trying to upload lists for reporting purposes that have inactive users listed?

  • I get this error about the file not found. Any Ideas?

    C:UsersUSERNAMEHEREDesktopRemoveUsersRemove-SPUserBulk.ps1 :
    At line:1 char:24
    + .Remove-SPUserBulk.ps1 <<<< -CSVPath "E:Users.csv"
    + CategoryInfo : NotSpecified: (:) [Remove-SPUserBulk.ps1], FileN
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Remove-SPUserBul

  • Far from perfect – ideally you’ll want the script to check against AD and remove users that no longer exist or were disabled in AD, not generate a manual list every day.

  • ^ What Alex said. Have you got a script that looks at all SP users then checks AD to see if they still exist? I would also be interested to see what the outcome is of a document library that a user last created/modified in – would their name disappear post deletion in SP or would this only remove them from site permissions lists? Thanks

  • What if I first would like to copy the permissions of a deleted users to a new existing AD account?

    I have script a script that can copy rights of an Active user to another active user. It uses GetUserEffectivePermissionInfo to et the permissions, but that does not work for a user that does not exist anymore in the AD.
    Any ideas?

  • Questions Concerning this:
    1) If you remove a user from the UIL (effectively removing them from people picker), how for that affect documents, lists, pages, etc. that was either created or modified by that user? Do you lose that history, does the field change to “System Account”, or does it remain? And if it remains, does it add anything to indicate that the user is no longer with the company? Red Text, maybe…
    2)Microsoft best practices are to use ‘SharePoint Groups’ instead of giving users direct permissions. If users are not given direct permissions and the groups are used, how is the UIL affected?

  • I can’t get the delete to work I have tried every thing.

    Here is my script
    $url= “”
    $web = Get-SPWeb $url
    $list = $web.Lists[“User Information List”]
    $name=”0002 Dowling BTA Allocation Committee – DL”
    $query = New-Object Microsoft.SharePoint.SPQuery
    $queryCamlString = “”+$name+””
    $query.IncludeMandatoryColumns = $false
    $query.DatesInUtc = $true
    $query.RowLimit = 10;
    $query.Query = $queryCamlString
    $userInformationListItems = $list.GetItems($query)
    $count =$userInformationListItems.Count
    Write-Output “$($count) count”
    echo $user.Title
    echo $user.ID ” ID ”

    echo $user.Name “name ”
    echo $user[“ows_Account”] “account”
    echo $user[“ows_Title”] “title”
    echo $user[“ows_Department”] ” dept”
    echo $user[“ows_JobTitle”] ” job title ”
    echo $user[“ows_EMail”] ” email ”

    #Remove-SPUser $z.UserLogin -web $site.URL -Confirm:$False
    #Remove-SPUser –Identity $user.UserLogin -web $site.URL -Confirm:$False
    #Remove-SPUser $user.UserLogin -web $site.URL -Confirm:$False
    #Remove the user from the User Information List
    #Remove-SPUser $user[“Account”] -Web $url -Confirm:$False
    #remove-spuser $list[$user.ID][“Account”] -web $url -confirm:$false

    remove-spuser $userInformationListItems[0][“Account”] -web $url -confirm:$false

  • There is an easier way to prevent users from showing in the People Picker. All you need to do is set an exclusion filter in the User Profile Service. After the user’s account is disabled in Active Directory they will not appear in the People Picker.

    To add a filter go to the User Profile Service Synchronization Connections page. Then click the drop down arrow beside the current connection and choose “Edit Connection Filters’. Add the Filter “User Account Control” Bit on Equal 2. Here is a link for details:

Leave a Reply

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