Add email addresses to users when a new domain is added

Whenever you connect you a domain to Office 365, new users will get the email addresses derived from the new domain, but existing users do not.

The next script adds 2 email addresses to existing users. E.g. when you add it will add and to the existing users.

$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange –ConnectionUri -Credential $LiveCred 
     -Authentication Basic -AllowRedirection
Set-ExecutionPolicy RemoteSigned
Import-PSSession $Session
$users = Get-Mailbox
foreach ($a in $users) 
   $myEmail = $a.firstname + $a.lastname
   $myEmail = $myEmail.replace(' ','') 

$users | %{Set-Mailbox $_.Identity -EmailAddresses $_.EmailAddresses}

Leave a Reply