Hide mail enabled security group from GAL using Powershell

Mail-enabled security group is nothing but the security group which also acts as a distribution list. The group’s security-related properties are controlled by Azure AD and Message distribution-related stuff is controlled by Exchange Online. So we can use the Exchange Powershell cmdlet Set-DistributionGroup to hide its mail address from Global Address List.

Set-DistributionGroup "mail security group name" -HiddenFromAddressListsEnabled:$true

We are setting the attribute HiddenFromAddressListsEnabled as true to hide group mail id from global address book. You can use the following command to set this property for all mail-enabled security groups.

Get-DistributionGroup -RecipientTypeDetails MailUniversalSecurityGroup | Set-DistributionGroup -HiddenFromAddressListsEnabled:$true

The below command lists all groups with GAL visible status:

Get-DistributionGroup -RecipientTypeDetails MailUniversalSecurityGroup | Select DisplayName,HiddenFromAddressListsEnabled

Advertisement

Leave a Comment