SharePoint 2013: Update User's Display Name using PowerShell

Requirement:  I came across an issue where the user display name appeared as domain/username instead of First name Last name.

Solution: We observed, If the user profile sync is not properly configured or running, we'll face this issue! Other than UPS solution, You can use PowerShell to update user's display name.
change user display name in sharepoint 2013
PowerShell to change user display name in SharePoint 2013:
How to change the SharePoint user display name with PowerShell? Well, You can use Set-SPUser cmdlet.  Just provide the account identity, site and the new display name for user user.

Run this PowerShell cmdlet from SharePoint Management Shell.
Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -DisplayName "Salaudeen Rajack" `
sharepoint powershell change user name
Sync User Account Details such as Display Name, E-mail, Department from Active Directory:
Sometimes, user account details may be updated in AD but not synced in SharePoint. If that's the case, you can force sync user account details such as display name, E-mail, department, etc from active directory with the below PowerShell script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#User Account to Sync and Site where the account exists

#Get the User's Current Display Name and E-mail
Get-SPUser -Identity $UserAccount -Web $WebURL | Select DisplayName,Email

#Force Sync from Active Directory
Set-SPUser -Identity $UserAccount -Web $WebURL -SyncFromAD

How to Re-Sync All users from Active Directory?
To re-sync all user details, use this PowerShell script:
Get-SPUser -Web http://web-app-url | Set-SPUser –SyncFromAD

Update User's Display Name for All sites:
Get-SPSite -Limit All | Get-SPWeb | Foreach-object {
  Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -DisplayName "Salaudeen Rajack" –Web $_ } 

1 comment:

  1. hi
    they have updated last name in active directory ,but it was not affected how can i synchronize through powershell



Please Login and comment to get your questions answered!

Powered by Blogger.