While at a client location this week I ran into the situation of their SharePoint deployment recognizing a handful of people by their Display Name and others (a lot more) by their “domain\username” account.
And since they had User Profile in place they felt something was just not right, and if you combine that and the fact most of the information available around that issue tells you it is a profile issue, you can understand the frustration of going back to the sync process and correcting in AD, trying this and that and nothing would fix it.
How else to fix it? Over time I have come to just rely on man’s best friend, I should say “SharePoint’s best friend, PowerShell will always have “a fix for that”. If we look at what is available, there is Get-SPUser and Set-SPUser.
What does Get-SPUser give me?
(more info on Get-SPUser)
The main thing I was after was to review the info on the user information store (details from AD) passed on to SharePoint. And there it was, it gave me back the username and the Display Name. The command used:
Get-SPUser –Web http://<name of web app>
Time to try what options Set-SPUser would allow me to use.
(More info on Set-SPUser)
As the premise for PowerShell goes, we are now used to seeing the type of commands, like Get which will help us retrieve information. Then we have Set, which will help us modify/change values.
The command to do a one user sync would like this:
Set-SPUser –Identity ‘<domain>\<username> –SyncFromAD –Web http://<name of web app>
And we are set …
What is it you say? What if this is to be done for every user?
Keep in mind PowerShell has an iterative nature.
Therefore, what if we combined both commands above to retrieve the user and then pass it on to the next command to synchronize from AD.
Here it is:
Get-SPUser –Web http://<name of web app> | Set-SPUser –SyncFromAD
Ok, that is it for now, give it a go and enjoy Display names with your SharePoint deployment.