How to Remove Spaces From Recipient Aliases by Using the Exchange Management Shell

Microsoft Exchange Server 2007 will reach end of support on April 11, 2017. To stay supported, you will need to upgrade. For more information, see Resources to help you upgrade your Office 2007 servers and clients.

 

This topic explains how to use the Exchange Management Shell to remove spaces from recipient aliases. In Microsoft Exchange Server 2003, you can create recipients with spaces in aliases. Exchange Server 2007 does not allow recipients to have spaces in their aliases.

When you try to manage a recipient with spaces in its alias using the Exchange 2007 management tools, you will experience the following issues:

  • When you try to view the properties of a recipient with spaces in its alias using the Exchange Management Console, you will receive the following error:

    The properties on <recipient name> have invalid data. If you click OK, default values will be used instead and will be saved if you do not change them before hitting Apply or OK on the property page. If you click cancel, the object will be displayed read-only and corrupted values will be retained. The following values have invalid data: Alias.

  • When you access a recipient with spaces in its alias using the Get- cmdlet in the Exchange Management Shell, you will receive the following warning:

    WARNING: Object <distinguished name of the recipient> has been corrupted and it is in an inconsistent state. The following validation errors have been encountered:

    WARNING: <alias of the recipient> is not valid for Alias.

  • When you try to update the properties of a recipient with spaces in its alias using the Set- cmdlet in the Exchange Management Shell, you will receive the following error:

    Set-<recipient type> : <alias of the recipient> is not valid for Alias.

  • You will not be able to move a mailbox with spaces in its alias to an Exchange 2007 server.

Resolution

If you have a mixed-mode environment with both Exchange 2003 and Exchange 2007 servers, you should remove the spaces from the aliases of your recipients.

Before You Begin

To perform this procedure, the account you use must be delegated the following:

  • Exchange Recipient Administrator role

For more information about permissions, delegating roles, and the rights that are required to administer Exchange 2007, see Permission Considerations.

Procedure

To use the Exchange Management Shell to remove the spaces from the aliases of your mailboxes

  • Run the following commands to remove the spaces from the aliases of your mailboxes. The first command locates all the mailboxes in your organization that have spaces in their aliases and stores them in the temporary variable $Mailboxes. The second command removes the spaces from the aliases of all the mailboxes stored in the temporary variable $Mailboxes.

    $Mailboxes = Get-Mailbox | Where {$_.Alias -like "* *"}
    ForEach($Mailbox in $Mailboxes) {Set-Mailbox $Mailbox.Name -Alias:($Mailbox.Alias -Replace " ","")}
    
  • As an alternative, you can combine the two preceding commands into a single Exchange Management Shell command.

    Get-Mailbox | Where {$_.Alias -like "* *"} | ForEach-Object {Set-Mailbox $_.Name -Alias:($_.Alias -Replace " ","")}
    

For detailed syntax and parameter information, see the Get-Mailbox and the Set-Mailbox reference topics.

Note

The preceding procedure shows how to remove spaces from the aliases of your mailboxes. The procedure is the same for mail contacts, mail users, and distribution groups. You only need to substitute the Get-Mailbox and Set-Mailbox cmdlets with the corresponding Get- and Set- cmdlets for each recipient type.

For More Information

To learn more about recipients in Exchange 2007, see Understanding Recipients.

For more information about managing recipients, see Managing Recipients.