Setting the SMTP address when an email policy won’t do the trick

I’m migrating a bunch of users from one domain to another. The client promised the end users that the first part of their email shall remain the same, only the domain changes. So, for example, if Bob Jones email address is Bob-the-dude@xyz.com , the default email policy would create bob.jones@abc.com, but the client promised the end users that it would be bob-the-dude@abc.com.

Input file that looks like this:

emailaddress,SamAccountName
bob-the-dude@abc.com,BJONES
happydoug@abc.com,DSMITH
theprez@abc.com,TSMITH

The script unchecks the “Automatically update e-mail addresses based on e-mail address policy”, and then it assigns a new primary smtp address.

$CSV = Import-CSV C:\temp\first50-smtp.csv
foreach ($entry in $Csv) {
Set-mailbox -identity $entry.samaccountname -EmailAddressPolicyEnabled $false -PrimarySmtpAddress $entry.emailaddress
}
Advertisements

About Mike

owner of blog
This entry was posted in 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 )

w

Connecting to %s