Updating the User Information List


SharePoint site collections contain a hidden list called the User Information List (UIL).  This list contains one entry for every user who has accessed the site collection or been given explicit rights within the site collection.  The list holds basic profile information.  In a farm that is not using a User Profile Application (UPA), most fields in the list items are editable.  In a farm that is using a UPA, the user is directed to a "profile" page within the My Sites host and the fields in the UIL are locked down (by default) because they get updated with data from the UPA.  This post will focus on the scenario where the farm is using a UPA.  Specifically, we will look at addressing an issue in which the UIL does not update properly.

If most environments that utilize a UPA, the UPA will be configured to pull information for user profiles from Active Directory (AD).  After the information comes from AD into the UPA, the "content" farm (could be the same farm that hosts the UPA or a separate farm) will execute an hourly timer job to update all site collections with the updated UPA information.  Occasionally (more often if your environment relies on a less-than-stable networking/virtualization infrastructure), you might encounter a situation in which a user's profile does not update in one or more UILs.  This can happen for a variety of reasons and most are environment-dependent.  The problem is that, if the sync process picks up 100 changes and only 99 are successful, the entire process is considered successful.  The next sync process will pick up changes that occurred AFTER the last sync completed, so the one profile that failed to update will not be retried.  This leads to a scenario in which the UPA has the correct information for a user, but that information is never making it to one or more UILs.  Theoretically, you could manually edit the user's profile within the UPA, which should trigger the changes to be picked up in the next sync process.  However, that is not guaranteed to work properly, so the script below can be used to update the UIL with the correct information.  The script can be expanded to loop through all site collections (there is one UIL per site collection) and/or pull a set of values directly from the appropriate UPA (to eliminate user error). 

DISCLAIMER:  This script is intended for use with the basic "display only" fields, such as Display Name, Job Title, Email, and Department.  It is not recommended to attempt to change fields that are integral to the operation of UIL functionality, such as the User Name or permission-related fields.  Additionally, UPA changes might eventually overwrite changes made directly to the UIL.

 

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

# Get the root web of the site collection. This could be changed into a loop that iterates through each site collection.

$web = Get-SPWeb-Identity <URLofwebapp>

$userID = "<user ID without domain - e.g. jdoe>"

 

# There is one User Information List per site collection. It resides in the root web.

$uil = $web.Lists["User Information List"]

# Find the specific user who has incorrect information in the User Information List of the site collection

$user=$uil.Items | ? {$_["ows_UserName"] -eq $userID}

 

Write-Output ("Values before update...")

$user["ows_Title"]

$user["ows_Department"]

$user["ows_JobTitle"]

$user["ows_EMail"]

 

Write-Output ("Updating values in the User Information List...")

$user["ows_Title"] = "My Display Name"

$user["ows_Department"] = "My Department"

$user["ows_JobTitle"] = "My Job Title"

$user["ows_EMail"] = "someone@somewhere.com"

$user.Update()

 

Write-Output ("Values after update...")

$user["ows_Title"]

$user["ows_Department"]

$user["ows_JobTitle"]

$user["ows_EMail"]

 

# Dispose of the web object

$web.dispose() 

Comments (1)

  1. rachel says:

    I can’t delete the item that i have found. The account no longer exist in AD.
    $url= “https://portal.peelschools.org”
    $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”
    $user=$userInformationListItems[0]
    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

    #$user.Delete(0)
    remove-spuser $userInformationListItems[0][“Account”] -web $url -confirm:$false

Skip to main content