Mail enabled security group powershell

Here are some PowerShell commands to manage mail-enabled security groups in Exchange:

Create a mail-enabled security group

New-MailContact -Name "Security Group Name" -ExternalEmailAddress "[email protected]" -RecipientTypeDetails MailEnabledSecurityGroup

Add members to a mail-enabled security group

Add-MailGroupMember -Identity "Security Group Name" -Members "[email protected]", "[email protected]", "[email protected]"

Remove members from a mail-enabled security group

Remove-MailGroupMember -Identity "Security Group Name" -Members "[email protected]", "[email protected]", "[email protected]"

Get the members of a mail-enabled security group

Get-MailGroupMember -Identity "Security Group Name" | Select-Object -ExpandProperty Name

Get the distribution group settings for a mail-enabled security group

Get-DistributionGroup -Identity "Security Group Name" | Select-Object -ExpandProperty Settings

Set the distribution group settings for a mail-enabled security group

Set-DistributionGroup -Identity "Security Group Name" -Settings @{ "AllowExternalSenders" = $true }

Remove a mail-enabled security group

Remove-DistributionGroup -Identity "Security Group Name" -Confirm:$false

Get all mail-enabled security groups

Get-DistributionGroup -RecipientTypeDetails MailEnabledSecurityGroup | Select-Object -ExpandProperty Name

Note: Replace "Security Group Name" with the actual name of the mail-enabled security group you want to manage.