header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

Change multiple ExternalEmailAddress feilds at once.
Last Post 02 Jul 2009 05:56 PM by kpeakman. 6 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
kpeakmanUser is Offline
New Member
New Member
Posts:5
Avatar

--
02 Jul 2009 03:52 AM  
I am in a scenario where I need to change a couple thousand email addresses at once. We are running E2K7 across two seperate forest using MS Identity Integration to replicate contacts between forest. 

I can filter down to the list of contacts that I need to have the ExternalEmailAddress changed for. I can then select all, then modify. However, this would change all of the ExternalEmailAddress for all of the contacts to the one static entry that I input.

What I need, in short, is a script that allows me to to change the value of the ExternalEmailAddress utilizing the Alias for each contact. I've tried different variations of %m thinking it would pull the Alias for the record and reconstruct the ExternalEmailAddress field, but what I end up with is -
SMTP:%m@mydomain.com

I would think that I could use a Set-MailContact at the end of this:

Get-MailContact | where { $_.'ExternalEmailAddress' -like '*@mydomain.com*' } | Select-Object -property 'Name', 'Alias', 'RecipientType', 'ExternalEmailAddress'

But, I am having issues! Any assistance would be appreciated.
KarlMitschkeUser is Offline
Basic Member
Basic Member
Posts:282
Avatar

--
02 Jul 2009 03:12 PM  
Try this one liner:

Get-MailContact -Filter {ExternalEmailAddress -like '*@mydomain.com'}|Select-Object alias |ForEach-Object {Set-MailContact -Identity $_.alias -EmailAddresses($_.alias +"@mydomain.com")-WhatIf}

Karl
http://unlockpowershell.wordpress.com
kpeakmanUser is Offline
New Member
New Member
Posts:5
Avatar

--
02 Jul 2009 04:11 PM  
That looks like exactly what I need. However, when I try to run this without the -whatif statement, I get the error

"The e-mail address for this recipient are automaticaly generated based on e-mail address policies. To modify the primary SMTP address for this recipient, you must disable automatic updating of e-mail addresses based on e-mail address policy".

I've tried running: Get-MailboxServer | Get-Mailbox | Set-Mailbox -emailAddressPolicyEnabled $false

But no luck there either.


KarlMitschkeUser is Offline
Basic Member
Basic Member
Posts:282
Avatar

--
02 Jul 2009 04:18 PM  
Try this:

Get-MailContact -Filter {ExternalEmailAddress -like '*@mydomain.com'}|Select-Object alias |ForEach-Object {Set-MailContact -Identity $_.alias -EmailAddresses($_.alias +"@mydomain.com") -emailAddressPolicyEnabled $false -WhatIf}

http://unlockpowershell.wordpress.com
kpeakmanUser is Offline
New Member
New Member
Posts:5
Avatar

--
02 Jul 2009 05:26 PM  
It's so strange.. running the script with the -whatif seems to work great. I can see a list roll by of everyone showing this:

What if: Setting Mail Contact "Nameofuser"

But when I run the script without the -whatif part, I get tons of errors like the following:

+ Get-MailContact -resultsize unlimited -Filter {ExternalEmailAddress -like '*@mydomainA.com'}|Select-Object alias |ForEach-Object {Set-MailContact <<<<
-Identity $_.alias -EmailAddresses($_.alias +"@mydomainB.com") -emailAddressPolicyEnabled $false }
Set-MailContact : The operation could not be performed because 'CSmith' matches multiple entries.
At line:1 char:141

Now, I can understand the error message. Clearly, I have two users that have an Alias of 'CSmith' - But what is troubleing, is that I when I go into EMS, after the script finishes, and fliter down for the contacts that have an externalemailaddress that contains @mydomainB, there are none? The script fails.
KarlMitschkeUser is Offline
Basic Member
Basic Member
Posts:282
Avatar

--
02 Jul 2009 05:36 PM  
That's my mistake;

Try this:

Get-MailContact -resultsize unlimited -Filter {ExternalEmailAddress -like '*@mydomainA.com'}|Select-Object alias |ForEach-Object {Set-MailContact -Identity $_.alias -emailAddressPolicyEnabled $false -ExternalEmailAddress ($_.alias +"@mydomainB.com") }
http://unlockpowershell.wordpress.com
kpeakmanUser is Offline
New Member
New Member
Posts:5
Avatar

--
02 Jul 2009 05:56 PM  
YES! That's the one. I can't thank-you enough! :)
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer