Corrupt Alias Name

One issue that has driven me nuts during Exchange 2003 to Exchange 2010 migrations is that Exchange 2010 doesn’t allow many configurations that are allowed by Exchange 2003. For example, if you have a space or some other illegal character in the alias field in Exchange 2003, it spits at you.

For example, if I run Get-DistributionGroup and any of the distribution groups have problems with illegal characters, I will receive the following for many of the distribution groups:

WARNING: The object With Spaces has been corrupted, and it’s in an inconsistent state. The following validation errors happened:

WARNING: Property expression “GroupName With Spaces” isn’t valid. Valid values are: Strings formed with characters from A to Z (uppercase or lowercase), digits from 0 to 9, !, #, $, %, &, ‘, *, +, -, /, =, ?, ^, _, `, {, |, } or ~.

One or more periods may be embedded in an alias, but each period should be preceded and followed by at least one of the other characters. Unicode characters from U+00A1 to U+00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCII string in the e-mail address, which is generated from such an alias.

Microsoft published a great article on the Exchange Team Blog on this topic that includes a script:

While the script looks solid, I am always leery of running somebody else’s scripts. Also, most security and change control teams want to know every in and out of script before it is run. So, I went through the script and cleaned it up and created a couple of different scripts. I broke it into two small scripts, one which is really just a few piped commands, so that I could review the list of distribution groups that have issues with their alias names and make sure there wasn’t anything critical in my list that should be done manually and communicated to everyone in the group.

In the first script, I capture all of the corrupt distribution group aliases. A similar script can be written to do the same thing for mailboxes. I went around and around on trying to capture the warning messages, which just don’t redirect to a file. What the short script does is simply capture the distribution group alias so that I can use them later.

Get-DistributionGroup -resultsize unlimited | where {$_.isvalid -ne $true} | select alias | export-csv c:\BadDLAlias.txt


In the second script, the alias can be fed into the script and it will replace a space (the character between the quotes) with nothing. This same script can be used to remove any open parenthesis by modifying the $i.replace(” “,””) with $i.replace(“(“,””) in the script. I used just the space as in the case when I put this together, I didn’t have anything other than spaces.

$BadDL = get-content c:\BadDLAlias.txt




foreach ($i in $BadDL) {

$new = $i.replace(” “,””)

set-distributiongroup $i -alias $new



You will probably want to add the –force switch so that you don’t have to confirm each distribution group change.

This entry was posted in Exchange. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s