Solved

Powershell command to update new accepted domain

Posted on 2014-09-09
8
255 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
 
LVL 24

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 40

Accepted Solution

by:
Subsun earned 500 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 24

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 500 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 24

Author Closing Comment

by:-MAS
ID: 40314687
Thanks a lot
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now