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

May 3, 2016 | Views: 11606

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

When 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 list

A 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 automatically

To 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"}

-xyra
http://miriamxyra.com – Miriam Wiesner

mx_microsoft_border

Share with Friends
FacebookTwitterGoogle+LinkedInEmail
Use Cybytes and
Tip the Author!
Join
Share with Friends
FacebookTwitterGoogle+LinkedInEmail
Ready to share your knowledge and expertise?
21 Comments
  1. ELGZZA,
    Here is an article that tells you how to do this with a vbscript. The script will need to be run as a logon script.
    https://technet.microsoft.com/en-us/magazine/2006.10.heyscriptingguy.aspx

    Good luck!

  2. hello i would like to ask how to create a uniformed signature for all staff using outlook mail

Page 3 of 3«123
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Cybrary On The Go

Get the Cybrary app for Android for online and offline viewing of our lessons.

Get it on Google Play
 

Support Cybrary

Donate Here to Get This Month's Donor Badge

 
Skip to toolbar

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel