Sharepoint 2010 Change your display of wellcome name


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 …

Advertisements

About bpostaci
Sr. Support Escalation Engineer in Microsoft.

5 Responses to Sharepoint 2010 Change your display of wellcome name

  1. Pingback: Sync SharePoint Foundation 2010 User Profiles To AD Using PowerShell | SharePoint Geek

  2. shobs says:

    I changed the display names using PS script but they keep coming back. Any idea?

    THanks

    • bpostaci says:

      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.

  3. Pete says:

    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.

  4. Pingback: Unable to sync user titles for Welcome name in SharePoint | Bugra Postaci's Blog

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: