Reputation: 69
I have the following, working well, After connecting to Exchange 2016 ( On-premise ):
$username = Read-Host -Prompt "`n Please provide AD-USERNAME to Migrate";
Enable-RemoteMailbox -Identity $username -RemoteRoutingAddress($username+'@MYORG.mail.onmicrosoft.com')
sleep 30
Get-RemoteMailbox $username|Set-RemoteMailbox -EmailAddressPolicyEnabled:$true
What i need to do now, is to set the a NEW smtp address per each mailbox that is created using that syntax.
In a diffrent script, i used something like the following to add additional SMTP`s and set them as default for mailboxes:
Set-RemoteMailbox $username -EmailAddresses @{add="$smtp"}
Set-RemoteMailbox $username -EmailAddressPolicyEnabled $false -PrimarySmtpAddress "$smtp"
Not sure, thats going to work here the same way, amyeb something more of that sort?
Get-RemoteMailbox $username| Set-RemoteMailbox $username -EmailAddresses @{add=$username+'@MYORG.com'}
Well im not sure where to go from here with the syntax to do what i need...would love some help.
Thanks in advance, everyone !
Upvotes: 0
Views: 10432
Reputation: 69
We've solved the issue internally by adding -PrimarySmtpAddress
To the initial Enable-RemoteMailbox
string, and by removing EmailAddressPolicyEnabled:$true
Alltogether.
$username = Read-Host -Prompt "`n Please provide AD-USERNAME to Migrate";
Enable-RemoteMailbox -Identity $username -RemoteRoutingAddress($username+'@MYORG.mail.onmicrosoft.com') -PrimarySmtpAddress($username+'@MYORG.com')
sleep 30
## Removed ## >> Get-RemoteMailbox $username|Set-RemoteMailbox -EmailAddressPolicyEnabled:$true
I appreciate everyone's effort. Thanks.
Upvotes: 0
Reputation: 656
As you are in a hybrid On-Prem and Cloud Exchange environment, and you wish to add a new email address alias to an existing on-prem mailbox, the below is how its done.
Set-RemoteMailbox cmdlet - configures Exchange attributes for an on-premises mail user. The configuration set on the on-premises mail user is synchronized to its associated mailbox in the service.
Get-RemoteMailbox cmdlet retrieves the mail-related attributes of a mail user in the on-premises Active Directory. It doesn't retrieve the attributes of the associated cloud-based mailbox. Most of the mail-related attributes of the on-premises mail user and the associated cloud-based mailbox should be the same. However, the cloud-based mailbox has additional attributes that you can't view by using this cmdlet.
Example Script to Add a New SMTP Address To Existing Mailbox
$users = ("user1", "user2")
foreach ($user in $users) {
$smtpdomain = "@MYORG.mail.onmicrosoft.com" # domain name
$username = $user.ToString() # user name to string
$emailadd = $username + $smtpdomain # String the user's prefix and new suffix together
$emailadd = $emailadd.ToString() # email address to string
Get-RemoteMailbox $user | Set-RemoteMailbox -EmailAddresses @{add=$newSMTP} # add email address
}
Use Exchange Online PowerShell to add email addresses to multiple mailboxes https://learn.microsoft.com/en-us/exchange/recipients-in-exchange-online/manage-user-mailboxes/add-or-remove-email-addresses
csv file containing usernames & email addresses
column headers are Mailbox and NewEmailAddress the delimiter is ','
Mailbox,NewEmailAddress
Dan Jump,[email protected]
David Pelton,[email protected]
Kim Akers,[email protected]
Janet Schorr,[email protected]
Jeffrey Zeng,[email protected]
Spencer Low,[email protected]
Toni Poe,[email protected]
Run the following command to use the data in the CSV file to add the email address to each mailbox specified in the CSV file.
Import-CSV "C:\temp\AddEmailAddress.csv" | ForEach {Set-RemoteMailbox $_.Mailbox -EmailAddresses @{add=$_.NewEmailAddress}
Upvotes: 0