How to change display name - all members in certain database

Hello all

I need to change the display name of all users in a database.

We have 2 databases, one for staff and one for students, there are some name clashes so we need to change the format of the display name in the student database to "secondname firstname" instead of the default "firstname secondname".

Can anyone supply a powershell script that will accomplish this please...

April 16th, 2015 5:31am

Hi,

Get the CSV file containing the SAM (AD) account name and a display name. You may export the user names from the database (Get-Mailboxdatabase|Get-mailbox |export-csv c:\accounts.csv) Use the following the PS script through PowerShell (Make sure that Active directory module is imported)

Import-Csv user.csv | Foreach { Set-ADUser -Identity $_.sAMAccountname -DisplayName $_.DisplayName }

Free Windows Admin Tool Kit Click here and download it now
April 16th, 2015 6:25am

Hi,

First of all, we can export the mailboxes in the student mailbox to csv/txt file with this command

Get-Mailboxdatabase DB name | Get-mailbox | select-object displayname | export-csv C:\mailbox.txt

Then, try this script.

$export = Get-Content "C: \Mailbox.txt"

foreach ($mbx in $Export){

 $mb = $mbx | Get-ADUser

}

foreach ($m in $mb) {

    $str1 = $m.GivenName #"FirstName"

    $str2 = $m.SurName #"LastName"

    Set-Mailbox $m.Name -DisplayName "$str2 $str1"  #"change display name"

}

Best Regards.

April 17th, 2015 3:43am

Hi,

You could try the adplus  tool .

Regards

Muthu

Free Windows Admin Tool Kit Click here and download it now
April 17th, 2015 12:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics