Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell command to update new accepted domain

Posted on 2014-09-09
8
Medium Priority
?
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
I don't pretend to be an expert at this, but I have found a few things that are useful. I hope that sharing them here will help others, so they will not have to face some rather hard choices. Since I felt this to be a topic of enough importance and…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

730 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