Category: SharePoint 2007

SharePoint – Problem with user changing it’s Name

Each time user interacts with SharePoint Content (Edits/Adds/Deletes) on the particular Site, SharePoint stores some user metadata (Email, DisplayName, LoginName, etc) in the ‘User Information List’ (hidden system list). That allows SharePoint to minimize the load on User Profile Application. That information is used to populate current user name (upper right corner in SharePoint 2013), Document Creator Name, Document Last Update by Name, etc.

In case when user interacted with the particular site before the name change, the old name would have been stored in the ‘User Information List’ and will be used from that point forward to populate document properties, User Info, etc.

Unfortunately, Removing the user from ‘User Information List’ of that particular site will remove that user permission on that site. You can use Set-SPUser command to update Display Name Property:

####################################################################################################
#
#  Author.......: David Shvartsman
#  Date.........: 06/28/2016
#  Description..: Updates Users Name in the 'User Information List'
#
####################################################################################################
if ((Get-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue) -eq $null) {
  Add-PSSnapin 'Microsoft.SharePoint.PowerShell'
}
 
cls
#Remove the Kerberos token prefix i:0#.w| if Kerberos Authentication is not being used
$userId = 'i:0#.w|<Domain>\<UserId>'
$UserDisplayName = '<User Full Name>'
 
CLS
$spAssignment = Start-SPAssignment
# Get All Web Applications
$WebApps=Get-SPWebApplication 
foreach($webApp in $WebApps) {
    foreach ($spSite in $webApp.Sites) {
        foreach($spWeb in $SPsite.AllWebs) {
            try {
                $user = $spWeb | Get-SPUser -Identity $userId -ErrorAction stop
                if ($user.DisplayName -ne $UserDisplayName) {
                    Write-Host "Updating Name $($user.DisplayName) in $($spWeb.Url)"
                    Set-SPUser  -Identity $userId  -web $spWeb.url -DisplayName $UserDisplayName -Confirm:$false
                }
            }
            catch {}
        }
    }
}
Stop-SPAssignment $spAssignment

To see the value of the User Information List Properties you can use the following code:

CLS
#Remove the Kerberos token prefix i:0#.w| if Kerberos Authentication is not being used
$userId = 'i:0#.w|domainName\userId'
$spWeb = Get-SPWeb -Identity 'Site URL'
$user = $spWeb.EnsureUser($userID)
$item = $spWeb.SiteUserInfoList.Items.GetItemById($user.ID)
foreach ($field in $item.fields) {
    Write-host 'Title: $($field.Title) ($($field.InternalName)) Value: $($item[$field.InternalName])'
}

Additional Information:

Set-SPUser
Get-SPUser

For more details on User Information se the TechNet post: https://gallery.technet.microsoft.com/User-Information-List-in-8b420e8c

The scripts work in SharePoint 2007, SharePoint 2010, SharePoint 2013, SharePoint 2016 and SharePoint Online Name>