Solved

Powershell command to update new accepted domain

Posted on 2014-09-09
8
256 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 25

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 25

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 25

Author Closing Comment

by:-MAS
ID: 40314687
Thanks a lot
0

Featured Post

Why are Office 365 signatures so complicated?

Trying to setup transport rules for Office 365 email signatures and can’t quite figure it out? Having to test the signature over and over? Make things simple by using Exclaimer Cloud - Signatures for Office 365.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Find out what you should include to make the best professional email signature for your organization.
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

867 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

21 Experts available now in Live!

Get 1:1 Help Now