Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Fantasillion/c4f4225bdea8c0fe7d00d675e5bfe35c to your computer and use it in GitHub Desktop.
Save Fantasillion/c4f4225bdea8c0fe7d00d675e5bfe35c to your computer and use it in GitHub Desktop.
Replace Primary Mail Address on Group
#Instructions for both O365 Groups and Distribution Lists
#For O365 Groups:
#1.a Find specific group name. Replace put group name here with the name of the group.
Get-UnifiedGroup -Identity "put group name here" | Select Name,@{Name="NameLength";Expression={$_.name.length}}, EmailAddresses, Alias, ServerName, AccessType
#1.b List all groups with names.
Get-UnifiedGroup | Select Name,@{Name="NameLength";Expression={$_.name.length}}, EmailAddresses, Alias, ServerName, AccessType
#2. Add mail address. Replace put group name here with the name of the group. Replace putmail address here with the new mail address.
Set-UnifiedGroup -Identity "put group name here" -EmailAddresses: @{Add ="put mail address here"}
#3. Replace primary address. Replace put group name here with the name of the group. Replace putmail address here with the new mail address.
Set-UnifiedGroup -Identity "put group name here" -PrimarySmtpAddress "put mail address here"
#For Distribution Groups:
#Same but Get-DistributionGroup and Set-DistributionGroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment