Link to home
Create AccountLog in
Avatar of PaulNSW
PaulNSWFlag for Norway

asked on

Exchange 2010 Powershell to update Aliases

We are rebranding soon and will need to change our primary SMTP address to the new company domain. I was going to use Email Address Policy, but our current email addresses do not match any of the AD fields (SAMaccount, Alias) - they are usually just the first 2 initials of a users name

So I thought if I bulk change the aliases to match the local part of their current SMTP, I could then use address policies

Or maybe it would be simpler to do a CSV export, change emails and then import again.

Either way I need some help with the Powershell to accomplish this!

I have the following code to bulk change the aliases, can you take a look at it and see if it makes sense before I run it?

#get all mailboxes
$list = Get-Mailbox

#process each mailbox
ForEach ($item in $list)
{
#get local side of email address
$user = Get-User $item
$localemail = $user.WindowsEmailAddress | select local

#set alias using left side of the email address
Set-Mailbox $item -Alias "$localemail"
}

Open in new window


Or, if you can show me how to add a new Primary SMTP using CSV import, while retaining all existing emails (and previous primary SMTP)
Avatar of Manpreet SIngh Khatra
Manpreet SIngh Khatra
Flag of India image

If you want to add modified email addresses that wouldnt be a par of your Email address policy .... please remember that the checkbox for "Automatically Apply Email address based on Policy" on the Email address tab or else it will be overwritten :)

- Rancy
SOLUTION
Avatar of GusGallows
GusGallows
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of PaulNSW

ASKER

Yep, quotes had to be removed, and then the Set-Mailbox command used with $localemail.local<br /><br />It then worked a treat<br /><br />Thanks!