Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Powershell command to update new accepted domain

Posted on 2014-09-09
8
Medium Priority
?
293 Views
Last Modified: 2014-09-10
I have added new accepted domain I would like to update the email address not by EAP I want to do by running command from powershell.  I got the below code from this site. But it is showing error
http://blogs.microsoft.co.il/scriptfanatic/2010/11/22/managing-email-addresses-in-exchange-2010/ 

$mbx = Get-Mailbox
$mbx | Foreach-Object {Set-Mailbox -Identity $_ -EmailAddresses @{‘-’=($_.Alias+’@contoso.com’)}
anyone can help
0
Comment
Question by:MAS
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 40313356
@{‘-’=(.. means remove.. Are you trying to remove the email address? Also please post the error.
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40313358
The command you are running is going to try and remove an email address of
Username@contoso.com from each user.  I thought you wanted to ADD?

Your Set-Mailbox command should be...

Set-Mailbox -identity $_ -EmailAddresses @{Add="$($_.Alias@YourDomain.com")

Replacing YourDomain.com with your new domain name


But it is FAR easier to just add a new policy or update your existing.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40313421
BTB, If you want to replace @some.com email address with @contoso.com then you can try the following code..
$mbx = Get-Mailbox -Resultsize Unlimited
$mbx | %{Set-Mailbox -Identity $_ -EmailAddresses @{Add=($_.Alias+'@contoso.com');Remove=($_.Alias+'@some.com')} -EmailAddressPolicyEnabled:$False}

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 27

Author Comment

by:MAS
ID: 40313701
I want to keep both domains and majority of the users are EAP disabled.
i.e. one user will have 2 email address user@olddomain.com and user@newdomain.com
I want to apply this on all users or atleast on EAP disabled users
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 40313934
$mbx = Get-Mailbox -Resultsize Unlimited 
$mbx | %{Set-Mailbox -Identity $_ -EmailAddresses @{Add=($_.Alias+'@contoso.com')}}

Open in new window

To add email try above code..
0
 
LVL 27

Author Comment

by:MAS
ID: 40313951
I want to do the same for distribution group as well
0
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 2000 total points
ID: 40314124
Replace *Mailbox commands with *DistributionGroup, I didn't test it but it should work..
$mbx = Get-DistributionGroup -Resultsize Unlimited
$mbx | %{Set-DistributionGroup -Identity $_ -EmailAddresses @{Add=($_.Alias+'@contoso.com')}}

Open in new window

0
 
LVL 27

Author Closing Comment

by:MAS
ID: 40314687
Thanks a lot
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Stellar Exchange Toolkit: this 5 in 1 toolkit comes loaded with mega-software tool. Here’s an introduction to tools’ usage and advantages:
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question