Powershell Exchange Commands

I am doing a migration from GroupWise to Exchange, here are some helper powershell commands I used to modify mail enabled and mailbox enabled users.

1. RemoveBADAddressesOnMBXusers.ps1 code:

foreach($mbx in Get-Mailbox -Resultsize unlimited){

$newaddrs = $mbx.EmailAddresses |? {$_ -notlike “gwise:UHD*”} |? {$_ -notlike “smtp:”+$mbx.alias}

set-mailbox $mbx -emailaddresses $newaddrs

}

Why we need it:

After we Mailbox enable a user (convert them from a mail enabled user in AD to a mailbox user) using the quest tool, we need to remove the old GroupWise address that points back to the GroupWise address. In addition, the Quest tool has a bug that stamps an invalid SMTP address on the user of just the username. (This invalid SMTP address occurs when we use the Quest tool to make the user mail enabled or mailbox enabled)

What it does:

It reads ALL mailbox users and removes any GroupWise email address that starts with UHD and the invalid SMTP address that is just the userid.

2. MailusersRemoveBadSMTPaddress.ps1

foreach($mu in Get-Mailuser -Resultsize unlimited){

$newaddrs = $mu.EmailAddresses |? {$_ -notlike “smtp:”+$mu.alias}

set-mailuser $mu -emailaddresses $newaddrs

}

Why we need it:

After we Mail enable a user using the quest tool, we need to remove the old invalid smtp address that it makes.

What it does:

It reads ALL mail enabled users and removes any invalid SMTP address that is just the userid.

3. gwise-mailbox-apply.ps1 (fix users that don’t have a gwise entry)

foreach($mbox in Get-Mailbox -Resultsize unlimited){

$mbox.EmailAddresses += (“gwise:Exchange.expo.” + $mbox.DisplayName)

Set-Mailbox $mbox -EmailAddresses $mbox.EmailAddresses

}

Why we need it:

After we Mailbox enable a user using the quest tool, we need to set the new GroupWise address that allows the Exchange mailbox user to be seen as a user in the GroupWise address book. The address is of the format Exchange.expo.display name. The “Exchange” is the External domain, the “expo” is the external post office, and the “display name” is the first name last name as it appears in Active Directory.

We had a Email address policy applying this address up until just recently, but it was inconsistent. So this PowerShell script does it for us.

What it does:

It reads all mailbox users, adds the address gwise:Exchange.expo.DisplayName

Advertisements

About Mike

owner of blog
This entry was posted in Exchange, PowerShell. Bookmark the permalink.

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