Sync SharePoint User Information List

SharePoint contains a User Information List in the Root Web of every Site Collection which contains a number of properties about the users.

The properties include:

  • Display Name
  • Email
  • SIP Address (Used by OCS/Lync Presence)
  • Department
  • Job Title
  • First Name
  • Last Name
  • Work Phone
  • Office
  • User Name

This List is used in a number of different places in SharePoint, such as workflows/alerts, custom applications, People Picker and many more. This List is supposed to be updated by a User Profile Service Timer Job. I have rarely seen this function work in a Production environment.

When this list becomes out of date, a number of issues could occur:

  • Alerts/Workflow Email sent to the wrong email
  • Assigning permissions to the wrong user
  • Custom Application relying on this information may behave incorrectly
  • The users Display Name in SharePoint may be wrong, it may be domain\alias or a random name

I have created this script which syncs all of the properties in the User Information List to the data in the User Profile Service. There are other scripts out there which will query AD for every user. I would not recommend running these scripts as you will be querying AD thousands of times as each Site Collection potentially contains similar users. Furthermore, the Set-SPUser command which they rely on only syncs the Display Name.


  • User Profile Service with Synchronization working
  • User Profile Service must be connected to the Central Administration Web Application
  • The Account running the script must have Rights to the User Profile Service and all Site Collections

Powershell script :

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0;  
$ErrorActionPreference = "SilentlyContinue";  
$PropertyMap=@("Title,PreferredName,Display Name",  
"MobilePhone,CellPhone,Mobile Phone",  
"Notes,AboutMe,About Me",  
"SipAddress,WorkEmail,Sip Address",  
"Picture,PictureURL,Picture URL",  
"JobTitle,SPS-JobTitle,Job Title",  
"FirstName,FirstName,First Name",  
"LastName,LastName,Last Name",  
"WorkPhone,WorkPhone,Work Phone",  
"SPSResponsibility,SPS-Responsibility,Ask About Me",  
$Context = Get-SPServiceContext $(Get-SPWebApplication -IncludeCentralAdministration | ? {$_.IsAdministrationWebApplication}).Url;  
$ProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($Context);  
    foreach ($Site in $(Get-SPSite -Limit All | ? {!$_.Url.Contains("Office_Viewing_Service_Cache")})){  
        $RootWeb = $Site.RootWeb;  
        Write-Host $($Site.Url);  
        foreach ($User in $($RootWeb.SiteUsers)){  
            if ($ProfileManager.UserExists($($User.UserLogin))){  
                $UPUser = $ProfileManager.GetUserProfile($($User.UserLogin));  
                $UserList = $RootWeb.SiteUserInfoList;  
                $Query = New-Object Microsoft.SharePoint.SPQuery;  
                $Query.Query = "<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>$($User.UserLogin)</Value></Eq></Where>";  
                $UserItem = $UserList.GetItems($Query)[0];  
                ForEach ($Map in $PropertyMap){  
                    $PropName = $Map.Split(',')[0];  
                    $SiteProp = $UserItem[$PropName];  
                    $UPSProp = $UPUser[$($Map.Split(',')[1])].Value;  
                    $DisplayName = $Map.Split(',')[2];  
                    if($PropName -eq "Notes"){  
                        #Write-Host "$DisplayName Updated: $SiteProp - $($UPSProp[0].Replace("&nbsp;"," "))";  
                        $UserItem[$PropName] = $($UPSProp[0].Replace("&nbsp;"," "));  
                    }elseif($PropName -eq "Picture"){  
                        #Write-Host "$DisplayName Updated: $($SiteProp.Split(",")[0]) - $($UPSProp[0])";  
                        $UserItem[$PropName] = $UPSProp[0];  
                    }elseif($PropName -eq "SPSResponsibility"){  
                        #Write-Host "$DisplayName Updated: $SiteProp - $($UPSProp -join ', ')";  
                        $UserItem[$PropName] = $($UPSProp -join ', ');  
                        #Write-Host "$DisplayName Updated: $SiteProp - $UPSProp";  
                        $UserItem[$PropName] = $UPSProp;  
                #Write-Host "Saving: $($User.UserLogin)";  
                #Write-Host "";  
        #Write-Host "";  
    Write-Host -foreground red "Cant connect to the User Profile Service. Please make sure that the UPS is connected to the Central Administration Web Application. Also make sure that you have Administrator Rights to the User Profile Service";  

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s