Home > Exchange 2010 > Remove spaces from mail-enabled public folder aliases

Remove spaces from mail-enabled public folder aliases

Mail enabled public folders’ aliases should not contain spaces, if they do you’ll see the following warning in the shell:

WARNING: The object … has been corrupted and it’s in an inconsistent state…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.

This script will go through all mail enabled public folders one at a time and remove spaces in aliases where it finds them:

#This script removes spaces in the alias of mail enabled public folders
#The illegal alias is replaced with the characters of the email address preceding the @ symbol

ForEach ($folder in (get-mailpublicfolder -ResultSize Unlimited | Where-Object{$_.alias -match '\s'}) {

#check for a space
if ($folder.alias -match '\s')
#determine new alias
$newAlias = $folder.WindowsEmailAddress.replace("@yourdomain.com","")
$newAlias = $newAlias -replace '\s|,|\.|\-';$_

#resize long PF aliases to below 32 characters
if($newAlias.Length -gt 31) { $newAlias = $newAlias.Substring(0,31)}

#rename PF alias
Set-MailPublicFolder -Identity $folderObject.WindowsEmailAddress -Alias $newAlias

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: