Sharepoint 2010 Change your display of wellcome name
22/06/2011 4 Comments
Instead of configure user profile syncronization and getting full dump some of users shown name has not able to change and still show user’s account name.Some scenarios it should be possible and if you want to change it manually there is a way to do it using powershell script on one site.
Set-SPuser -identity “DOMAIN\accountname” -DisplayName “Name Surname” -web <URL of Site>
Example:
Set-SPUser -identity “BLOG\admin” -DisplayName “Bugra POSTACI” -web http://blog.bugrapostaci.com
And also you can use by syncAD option .
Set-SPUser -Identity “DOMAIN\accountname” -SyncFromAD -web <URL of Site>
Example:
Set-SPUser -identity “BLOG\admin” -SyncFromAD -web http://blog.bugrapostaci.com
But what if your boss want you to add extra necessity to join your name with your title.
Like:
Bugra POSTACI ( Senior Sharepoint Support Engineer)
you can use this powershell script:
#Add SharePoint PowerShell SnapIn if not already added
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$site = new-object Microsoft.SharePoint.SPSite("http://blog.bugrapostaci.com");
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);
$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
$AllProfiles = $ProfileManager.GetEnumerator()
foreach($profile in $AllProfiles)
{
$Title = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::Title].Value
$AccountName= $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
$PreferredName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::PreferredName].Value
if( $PreferredName -ne "None" -and $Title -ne $null )
{
write-host "Profile: ", $PreferredName,"(",$Title,")"
$dName = $PreferredName + " (" + $Title + ")"
#you can add update your users displayname like below
Set-SPUser -identity $AccountName -Displayname $dName -web http://blog.bugrapostaci.com
}
}
write-host "Finished."
$site.Dispose()
If you just want to update all content database userinfo table with profile user names . You can use fallowing script.
#Add SharePoint PowerShell SnapIn if not already added
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
if( $args.Length -eq 0) {
write-host "Usage : Missing <URL>"
exit
}
$site = new-object Microsoft.SharePoint.SPSite($args[0]);
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);
$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
$AllProfiles = $ProfileManager.GetEnumerator()
foreach($profile in $AllProfiles)
{
$AccountName= $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
$PreferredName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::PreferredName].Value
if( $PreferredName -ne "NONE" )
{
write-host "Profile: ", $PreferredName , $Accountname
Set-SPUser -identity $AccountName -Displayname $PreferredName -web $args[0]
write-host "OK"
}
}
write-host "Finished."
$site.Dispose()
Have a nice scripting …

Pingback: Sync SharePoint Foundation 2010 User Profiles To AD Using PowerShell | SharePoint Geek
I changed the display names using PS script but they keep coming back. Any idea?
THanks
Check your user profile service configuration, also your problem depends on which sharepoint 2010 version in use or which CU installed. my lucky guess is full profile sync should overriding your changed data.
Hi
Thank you for this useful blog. I know its old but the post below may help others as inexperienced as I. My issue was probably too obvious to have anyone post the internet for lol.
I had a similar issue trying to change the displayname that was incorrecly set as domain\user instead of firstname surname using the Sharepoint 2010 Management Shell. I havent synced AD either.
I ran as administrator logged in as me (Farm Admininstrator) no joy.
It only worked by Running the Sharepoint 2010 Management Shell “as” the site admin account that was used to install Sharepoint. Then it worked. I used the command above
Set-SPUser -identity “Domain\user” -SyncFromAD -web http://SharepointServer/sites/sitename
Worked a treat.
Great post, this helped me get the syntax right and trial and error eventually got my solution.