RSS

remove started , contained and ended whitespace for exchange object.

07 Apr

you may get a lot of error that shows leading and trailing whitespace in displayname or aliasname is the root cause in EMS. So you may want to remove such whitespaces but feel it is not so easy to change so many object, let’s say 10000 entries. here is an easy method to help on this.

notice that you should check you have sufficient privilege such as domain admin member.

Remove  started or ended whitespace

A .net mathod called trim can help.

Get-Mailbox  -resultsize unlimited | Foreach { Set-Mailbox -Identity $_.Identity -DisplayName $_.DisplayName.Trim() }

Get-DistributionGroup -resultsize unlimited  | Foreach { Set-DistributionGroup -Identity $_.Identity -DisplayName $_.DisplayName.Trim() }

Remove contained whitespace

replace function can help
Get-mailbox -ResultSize Unlimited | Where {$_.Alias -like "* *"} | % { Set-mailbox $_.identity -Alias:($_.Alias -Replace " ","") }

Get-DistributionGroup -ResultSize Unlimited | Where {$_.Alias -like "* *"} | % { Set-DistributionGroup $_.identity -Alias:($_.Alias -Replace " ","") }

Advertisements
 
 

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 )

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

 
%d bloggers like this: