Skip to content

Instantly share code, notes, and snippets.

@johnarok
Last active June 23, 2018 02:47
Show Gist options
  • Save johnarok/a15207ca9f8db7713e9d8f4cce482e2b to your computer and use it in GitHub Desktop.
Save johnarok/a15207ca9f8db7713e9d8f4cce482e2b to your computer and use it in GitHub Desktop.
add email aliases to office365 group

Connect to Exchange online

Set-ExecutionPolicy RemoteSigned
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication  Basic -AllowRedirection
Import-PSSession $Session

Inquire

get-unifiedgroup <groupname> | format-list

Replace email addresses

$a=get-unifiedgroup <groupname>
$b=$a.EmailAddresses
$b += "SMTP:<new-email-address>" 
Set-UnifiedGroup -Identity <groupname> -EmailAddresses $b
Set-UnifiedGroup -Identity <groupname> -PrimarySmtpAddress <correct-email-address>

Better alternative

Set-UnifiedGroup -Identity <groupname> -EmailAddresses @{Add="SMTP:<new-email-address>"}

Disconnect from EOL

Remove-PSSession $Session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment