Friday, November 25, 2016

SharePoint People Picker Showing deleted AD users

The problem here is “People Picker showing deleted AD users”.

 This happens because the people picker retrieves data from multiple sources:

- User Information List (UIL)
 - Active Directory

User profile service application sync information from Active directory and updates SharePoint User Information List but it doesn't delete user from it.

we have to remove users from hidden user information list,  for Quick fix 

In SharePoint 2010:

http://your-sharepoint-site/_layouts/people.aspx?MembershipGroupID=0

In SharePoint 2013:

<URL>/_layouts/people.aspx?MembershipGroupId=0
or
<URL>/_layouts/15/people.aspx?MembershipGroupId=0

You can now select the user and click on “Actions –> Delete Users from Site Collection

PowerShell Script to fix SharePoint People Picker Showing Deleted Users:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define the Array with List of Users
$Users =@('Domain\abc', 'Domain\xyz')

#Get all Site Collections
$SiteColl = Get-SPWebApplication "Web application url" | Get-SPSite -Limit All

#Iterate through all Site Collections
foreach($site in $SiteColl)
{
 #Iterate through the users to Remove
 foreach($user in $Users)
 {
   #Check if User Exists in Site
   if ($Site.RootWeb.SiteUsers | Where {$_.LoginName -eq $User})
   {
      $Site.RootWeb.SiteUsers.Remove($User)  #You can also use: Remove-SPUser cmdlet
   Write-Host "$($user) has been Removed from $($Site.RootWeb.URL)"
   }
  }
  
}

No comments:

Post a Comment