Managing Mail-Enabled Security Groups with PowerShell
Mail-enabled security groups can be used to distribute messages as well as to grant access permissions to resources in Active Directory.
Parent Topic: PowerShell Exchange Online Commands Related: PowerShell Comprehensive Guide
Prerequisites
Ensure you are connected to Exchange Online:
Connect-ExchangeOnline
Creating a Mail-Enabled Security Group
New-DistributionGroup -Name "IT Security Team" `
-Alias "itsec" `
-PrimarySmtpAddress "itsec@yourdomain.com" `
-Type Security
Note: The New-DistributionGroup cmdlet is used with the -Type Security parameter.
Managing Members
Add a Member
Add-DistributionGroupMember -Identity "IT Security Team" -Member "jdoe@yourdomain.com"
Remove a Member
Remove-DistributionGroupMember -Identity "IT Security Team" -Member "jdoe@yourdomain.com" -Confirm:$false
Get Group Members
Get-DistributionGroupMember -Identity "IT Security Team"
Common Tasks
Hiding from Global Address List (GAL)
Set-DistributionGroup -Identity "IT Security Team" -HiddenFromAddressListsEnabled $true
Return to PowerShell Exchange Online Commands