Update Users Display Name after Enabling Forms-based Authentication (FBA) in Microsoft SharePoint Server 2010
Introduction
This script updates users display name after enabling Forms-based authentication (FBA) in Microsoft SharePoint Server 2010.
Scenarios
After enabling form-based authentication, you may want to change users display name to friendly ones. Nowadays, you may notice that some display names are showed in this form, i:0#.f|membership|username. Suppose you need to manage a large number
of site collections with FBA enabled, change display names will be a time-consuming task for you.
Script
This script contains one advanced functions: Update-OSCSPFBAUserDisplayName. You can use this script in the following way.
1. Open SharePoint 2010 Management Shell.
2. Run Import-Module cmdlet to import this module file.
Import-Module filepath\scriptname.psm1
Here are some code snippets
for your references. To get the complete script sample, please click the download button at the beginning of this page.
PowerShell
Edit|Remove
powershell
if ($spUser.DisplayName -ne $newDisNames[$specLogin]) {
$verboseMsg = $Messages.UpdateDisplayName
$verboseMsg = $verboseMsg -f $spUser.DisplayName,$($newDisNames[$specLogin])
$pscmdlet.WriteVerbose($verboseMsg)
$spUser.DisplayName = $newDisNames[$specLogin]
$spUser.Update()
} else {
$verboseMsg = $Messages.DisplayNameUpdated
$verboseMsg = $verboseMsg -f $spUser.UserLogin
$pscmdlet.WriteVerbose($verboseMsg)
}
if ($spUser.DisplayName -ne $newDisNames[$specLogin]) {
$verboseMsg = $Messages.UpdateDisplayName
$verboseMsg = $verboseMsg-f $spUser.DisplayName,$($newDisNames[$specLogin])
$pscmdlet.WriteVerbose($verboseMsg)
$spUser.DisplayName = $newDisNames[$specLogin]
$spUser.Update()
} else {
$verboseMsg = $Messages.DisplayNameUpdated
$verboseMsg = $verboseMsg-f $spUser.UserLogin
$pscmdlet.WriteVerbose($verboseMsg)
}
Examples
Example 1: How to display help about Update-OSCSPFBAUserDisplayName.
To display help about this function, run this command.
Get-Help Update-OSCSPFBAUserDisplayName -Full

Example
2: How to confirm the users
whose display name will be updated.
To confirm the users whose display name
will be updated, please run this command.
Update-OSCSPFBAUserDisplayName
-SiteURL "http://server_name/sites/sitename" -NewDisplayname @{"johnd"="John Doe";"janed"="Jane Doe"} -Whatif

Note: Update-OSCSPFBAUserDisplayName
checks the state of Forms-based Authentication (FBA) for specified site.
Example
3: How to update the display
name by using NewDisplayName parameter.
To update the display name by using
NewDisplayName parameter, please run this command.
Update-OSCSPFBAUserDisplayName
-SiteURL "http://server_name/sites/sitename" -NewDisplayname @{"johnd"="John Doe";"janed"="Jane Doe"} -Verbose

Example
4: How to update the display
name by using CsvFilePath parameter.
To update the display name by using
CsvFilePath parameter, please run this command.
Update-OSCSPFBAUserDisplayName
-SiteURL "http://server_name/sites/sitename" -"c:\Scripts\040\logins.csv" -Verbose

Note:
The .CSV file must have two column headers, “UserLogin” and “NewDisplayName”. Here is one example of the .CSV file.
"UserLogin","NewDisplayName"
"johnd","John Doe"
"janed","Jane Doe"
Example
5: How to update the display
name by using NewDisplayName parameter and ExactlyMatch parameter.
To update the display name by using
NewDisplayName parameter and ExactlyMatch parameter, please run this command.
Update-OSCSPFBAUserDisplayName
-SiteURL "http://server_name/sites/sitename" -NewDisplayname @{"i:0#.f|ldapmember|johnd"="John Doe;"janed"="Jane Doe"} -Verbose
Note:
If you choose to use ExactlyMatch parameter, it indicates that the user login should be provided in this form, @{"i:0#.f|providername|username"="DisplayName"}
Additional Resources
Technical Resources:
Forum Threads: