Solved

Powershell command to update new accepted domain

Posted on 2014-09-09
8
263 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

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

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.

Question has a verified solution.

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

This article explains how to install and use the NTBackup utility that comes with Windows Server.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
This video discusses moving either the default database or any database to a new volume.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 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