Home 0P3N Blog Exchange: How to Hide Disabled Users from the Global Address List (GAL)
Ready to Start Your Career?
Create Free Account
xyra s profile image
By: xyra
May 3, 2016

Exchange: How to Hide Disabled Users from the Global Address List (GAL)

By: xyra
May 3, 2016
xyra s profile image
By: xyra
May 3, 2016
Exchange: Hide Disabled Users from the Global Address List (GAL) - CybraryWhen a user leaves the company, often the Exchange mail account is deleted and the user account gets disabled.In this way, the former employee can not access corporate data, but he still appears in the Global Address List (GAL) for internal staff. He can still be selected in the address book and is also still visible in the team calendar.The reason for this lies in the fact that the account is still in the Active Directory and in the attribute msExchHideFromAddressLists, which contains no value. If this attribute is set to TRUE, the user disappears from the Global Address List and from certain calendar groups.To ease the work with disabled users, you can use the following PowerShell CMDlets.

Keep track every time

Which disabled users are still showing up in the address list?To find out which disabled users are still showing up in the GAL, you can use the following CMDlet:
Get-ADUser ` -Filter {(enabled -eq "false") -and (msExchHideFromAddressLists -notlike "*")} ` -SearchBase "OU=<OrganisationalUnit>,DC=<Domain>,DC=<TLD>"` -Properties enabled,msExchHideFromAddressLists
Which disabled users won’t be displayed anymore?If you want to display all disabled users where the attribute is already set to TRUE – those who won’t show up in the GAL anymore – this command will help you:
Get-ADUser ` -Filter {(enabled -eq "false") -and (msExchHideFromAddressLists -like "*")} ` -SearchBase "OU=<OrganisationalUnit>,DC=<Domain>,DC=<TLD>"` -Properties enabled,msExchHideFromAddressLists
Hide single users from the address listA single user, which username is known, you can hide with this command:
Set-ADUser <Username> -Add @{msExchHideFromAddressLists="TRUE"}
This can be helpful if you created a script to disable former users. In this case you can pass the username in a variable.Hide disabled users automaticallyTo ease this task, you can create a scheduled task. In this way every disabled user, who is still showing up in the GAL, is picked and the belonging attribute msExchHideFromAdressLists is set to TRUE.
Get-ADUser ` -Filter {(enabled -eq "false") -and (msExchHideFromAddressLists -notlike "*")} ` -SearchBase "OU=<OrganisationalUnit>,DC=<Domain>,DC=<TLD>"` -Properties msExchHideFromAddressLists | ` Set-ADUser -Add @{msExchHideFromAddressLists="TRUE"}
-xyrahttp://miriamxyra.com – Miriam Wiesnermx_microsoft_border
Schedule Demo

Build your Cybersecurity or IT Career

Accelerate in your role, earn new certifications, and develop cutting-edge skills using the fastest growing catalog in the industry