Requirement: Change user display name in SharePoint Online using PowerShell
How to Change the Display Name of the User in SharePoint Online?
When working with SharePoint Online, there may be instances where you need to update a user’s display name. Perhaps you have an employee whose last name has changed, and you need to change their name in the system. In this blog post, we will show you how to update the display name of a user in SharePoint Online.
If your Office 365 tenant is configured to sync user accounts from On-Premises Active Directory, then change the user name there first! Then it will be propagated to Office 365 and then SharePoint Online. In case you have two-way sync enabled or managing user accounts from the Office 365 portal, do the following to change the user display name:
- Login to Microsoft Admin Center at: https://admin.microsoft.com
- Expand Users >> Active Users >> Search and Select the User
- In the user properties panel, click on “Manage Contact Information” link and then update the user’s display name and click on “Save Changes”.
This changes the user name in Office 365, and the SharePoint user profile sync timer job eventually reflects this change once it’s executed.
Update User Display Name in Azure AD using PowerShell
The above steps can be scripted with PowerShell. Make sure you have the Azure AD PowerShell module installed (If not, install it with Install-Module -Name AzureAD)
Import-Module AzureAD -DisableNameChecking #Parameter - Login ID of the User $UPN = "[email protected]" $Displayname = "Steve Johnson" #Connect to Azure AD Connect-AzureAD -Credential (Get-Credential) #Change Display Name of the User Set-AzureADUser -ObjectId $UPN -Displayname $Displayname
Change user display name in SharePoint Online using PowerShell
Here is the PowerShell to update the display name manually.
Please note, the above PowerShell script updates the user display name only for the given site. You may have to loop through each site in the tenant and change the display name of the user.
#Parameters $SiteURL = "https://crescent.sharepoint.com/sites/Projects" $UserID = "i:0#.f|membership|[email protected]" $NewDisplayName = "Steve Johnson" #Connect to the site Connect-PnPOnline -Url $SiteURL -Interactive #Get the user $User = Get-PnPUser -Identity $UserID #Update the display name $User.Title = $NewDisplayName $User.Update() Invoke-PnPQuery
If you are looking to update the display name in SharePoint on-premises, please see this article: How to Update SharePoint User’s Display Name using PowerShell?