Powershell Needful Things put that in your pipeline


Repair Exchange mailbox display name case

We had a problem at one of our customers, where the users were created (by someone else :)) in ALL CAPS. This is more of an annoyance that anything else so I wrote a little script to read the names, and set the case from UPPER CASE to Proper Case.

You obviously have to run this from the Exchange Management Shell.

You can copy the code for the script from here:

$mailboxes = Get-Mailbox

foreach ($mbx in $mailboxes)
        write "..currenntly processing:" $mbx.Name
        $oldName = $mbx.Name.ToString().Split(' ')
        $newName = ($oldName | foreach {$_.Substring(0,1) + $_.SubString(1).ToLower()})
        $mbx | set-mailbox -name $newName -displayname $newName
Comments (6) Trackbacks (0)
  1. Would like to use this script but I’m getting an error.

    Set-Mailbox : Cannot convert ‘System.Object[]’ to the type ‘System.String’ required by parameter ‘DisplayName’. Specified method is not supported.

    This is in an Exchange 2007 SP3 environment.

    Any ideas?

    • Dave,

      The last server I used this on was 2010, but I see no reason why it shouldn’t work on 2007.

      Let me see if I can get some time today to test it on 2007 and get back to you.

      Thanks for visiting the site.

      • Thanks Jean…ideally this environment will be upgraded to Exchange 2010 but it won’t be for a bit yet so I’m just trying to get it looking good before then…not to mention I’d like to slap my help desk for creating IDs in all upper case.

        • Hi Dave,

          Aaah the age old feud between help desk and server support :).

          Please try the following code. I needed to force the newName variable to a string for some reason:

          remove-variable mailboxes
          $mailboxes = Get-Mailbox jean.louw

          foreach ($mbx in $mailboxes)
          write “..currenntly processing:” $mbx.Name
          $oldName = $mbx.Name.ToString().Split(‘ ‘)
          [string]$newName = ($oldName | foreach {$_.Substring(0,1) + $_.SubString(1).ToLower()})
          $mbx | set-mailbox -name $newName -displayname $newName

          I have tested it successfully on an Exchange 2007 test server. You will notice that the get-mailbox command at the top, is forced to get only 1 mailbox at the moment. You can remove that, but it is a way to test the script before running it in production.

          Hope this can save you some time.


          • Excellent…worked in my test environment. I actually omitted the -name from the set-mailbox cmdlet as keeping the username all CAPS really is of no concern of mine and it stays consistent with the rest of the environment however changing the display name will definitely make the end users happy.

            Thanks again 🙂

          • Great stuff! Glad I could help.

Leave a comment

No trackbacks yet.