5/25/11

Corrupt exchange 2003 conference room mailboxes

I recently started moving mailboxes from 2003 to 2010 SP1. When it came time to move the conference room mailboxes it was a no go.

Specifically Exchange 2010 SP1 states that these mailboxes are in an inconsistent state because validation can not be performed upon on the the attributes.

The attribute in question was the "mailNickname" attribute. It turns out that my conference room mailboxes have whitespace and a trailing decimal or period. Both of these character uses are illegal in Exchange 2010 SP1.

The solution?

Luckly all of the conference room mailboxes are in a single OU in AD.

I wrote a script to perform the actions of replacing whitespace with an underscore and removing any number of trailing period characters.

Function Remove-Spaces {
param($target)

begin {
filter Do-RemoveSpaces { $_ -replace "\s *", "_" }
}

process { if($_) { $_ | Do-RemoveSpaces } }

end { if($target) {$target | Do-RemoveSpaces} }
}

#$objArray = get-mailbox -identity "QuandaryPeak"
#$objArray = get-mailbox -organizationalunit "hq.corp.viasat.com/ViaSat West/Resource Mailboxes/Conference Rooms"

foreach($obj in $objArray)
{
$tempstring = $obj.alias
$tempstring = remove-spaces $tempstring
$tempstring = $tempstring.trimend(".")
set-mailbox -identity $obj -alias $tempstring
}

You must uncomment, remove '#' char, to make the program work. You use get-mailbox to gather the objects you want to process.

One odd side affect I found was that it sets the new alias as the primary SMTP reply address in hour system. I don't have access to 2003 so this is probably to be expected via the 2003 configuration. I alternatively looked at writing a similar program using get-ADObject and set-ADObject modifying the property directly without using the set-mailbox cmd-let would prevent setting the primary SMTP reply address to the alias.

References: http://msdn.microsoft.com/en-us/library/system.string_methods.aspx
References: http://powershell.com/cs/blogs/tips/archive/2009/09/14/trap-and-try-catch.aspx

No comments: