Script to convert the displayname and set as new displayname

Hi All,

Need a favor to convert the existing displaynames to right format and then set the displayname for bulk mailboxes.

Current Displayname - "Ranji Rock MBA\DBA\RISK\FIN"

I need a script to convert the above text to "Ranji Rock MbaDbaRiskFin" and set it as displayname. Could someone help me to remove those slashs in the text and adding the first letter in

March 17th, 2015 7:12pm

Something along these lines should work:

$mb = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited

foreach ($m in $mb) {

    $str = $m.DisplayName #"Ranji Rock MBA\DBA\RISK\FIN"

    $str2 = $str.Split(" ")
    $keep = $str2[0..($str2.count-2)] -join " " #"Ranji Rock"

    $str2[-1].Split("\") | % {

        $transform += $_.substring(0,1) + $_.substring(1).ToLower() #"MbaDbaRiskFin"

    }

    Set-Mailbox $m.Identity -DisplayName $keep + " " + $transform -whatif #"Ranji Rock MbaDbaRiskFin"

}

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2015 8:56am

Hi,

I suggest to ask this question to Script Center or create a new thread on Script Forum for more help.

Best Regards.

March 23rd, 2015 5:05am

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

Other recent topics Other recent topics