The following walkthrough will hide public folders and sub folders from the GAL. The attribute can also be modified from ADSI directly without using PowerShell.
PowerShell Script: This script will connect to exchange online and hide all public folders from the GAL
UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/https://protect-au.mimecast.com/s/rgAtCxnMKyUR2A7nf8tg5L?domain=outlook.office365.com -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking
Get-MailPublicFolder | Set-MailPublicFolder -HiddenFromAddressListsEnabled $True
ADSI: This will allow you to select specific users/groups/OU’s/public folders/etc. from active directory to hide from the GAL.
- Open ADSI Edit
- Right-click and the object you want to edit
- Select properties
- Look for the attribute called “msExchHideFromAddressLists”
- Change this value to “TRUE” to hide from the GAL