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 …

Advertisement

About bpostaci
Escalation Engineer in Microsoft.

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 )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: