Hide Office 365 Group from GAL using PowerShell
Requirement: Hide Office 365 Group from GAL (Global Address List).
How to Hide a Microsoft 365 Group from GAL?
By default, when you create an Office 365 group, it is visible in the Global Address List (GAL). You can hide any Office 365 group from GAL by settings its property “Don’t show team email address in Outlook” from Microsoft 365 Admin center. Here is how:
- Open the Office 365 Admin Center and go to the Groups section.
- Click on the group that you want to hide from the GAL.
- In the group settings, click on the “Don’t show Team email address in Outlook” check box.
- Click on “Save” to save the changes.
This will make the Office 365 group private, and it will no longer be visible in the GAL. BTW, You can also set the group privacy to “Private” so that it is visible only to the group members!
How to Hide Office 365 Group from GAL using PowerShell?
If you don’t wish your Office 365 group appears in the global address list, you can hide it using the Set-UnifiedGroup cmdlet. Here is how to hide the group from the address list:
#Get Credentials to connect
$Credential = Get-Credential
#Connect to Exchange Online
Connect-ExchangeOnline -Credential $Credential -ShowBanner:$False
#hide office 365 group from gal using powershell
Set-UnifiedGroup -Identity "[email protected]" -HiddenFromAddressListsEnabled $True
#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False
This PowerShell hides Office 365 Group from GAL. Similarly, You can hide Office 365 group from Exchange clients using the:
Set-UnifiedGroup -Identity "[email protected]" -HiddenFromExchangeClientsEnabled:$True
This hides the group from the Groups section in Exchange clients like OWA.
Hide All Microsoft Team’s Groups from Outlook
Let’s hide all groups created as part of Microsoft Teams:
#Connect to Exchange Online
Connect-ExchangeOnline -ShowBanner:$False
#Get All Microsoft 365 Groups created as part of Teams
$TeamsGroups = Get-UnifiedGroup -Filter {ResourceProvisioningOptions -eq "Team"} -ResultSize Unlimited
#Hide the gropus from GAL
ForEach ($Group in $TeamsGroups)
{
If($Group.HiddenFromAddressListsEnabled -eq $False)
{
Set-UnifiedGroup -Identity $Group.ExternalDirectoryObjectId -HiddenFromExchangeClientsEnabled:$True -HiddenFromAddressListsEnabled:$True
Write-Host "Group Set to Hidden from GAL:" $Group.DisplayName -f Green
}
}
Is there a way to apply it to all groups?