Hide disabled users from Exchange 2007 GAL via PowerShell

By | July 13, 2011


I have updated this script with a better one, please see this post: http://etcforge.com/2011/07/better-faster-simpler-script-to-hide-those-mailboxes-from-the-gal/

In our environment we retain disabled users for quite sometime for auditing reasons. Sometimes the workflow to manually hide or remove their mailboxes from Exchange does not happen. This script will query all disabled users, match them to an Exchange mailbox (if possible), and set the flag to hide them from the Global Address List. This requires Quest ActiveRoles and Exchange 2007 Management Tools installed from the run location.

Once this script runs, it will also force an update of the offline address book.

# Add Quest / Exchange Snaps
Add-PSSnapin Quest.ActiveRoles.ADManagement # Adds Quest "qaduser" commands
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin # Adds Exchange Shell Commands

# Squelches errors

$user = get-qaduser -disabled -sizelimit 0 | select samaccountname

foreach($name in $user){
set-mailbox $name.samaccountname -HiddenFromAddressListsEnabled $True

# Force update of OAL Generator
Get-OfflineAddressBook | Update-OfflineAddressBook

# Pause script for 30 seconds
Start-Sleep -s 30

# Force update of OAB on CAS
Get-ClientAccessServer | Update-FileDistributionService

3 thoughts on “Hide disabled users from Exchange 2007 GAL via PowerShell

  1. Stephen

    This is totally useless information but I’m adding it anyway.


    1. Beaz Post author

      Depends on if you’re running from a 64 or 32-bit machine, this won’t install on 32-bit. It’s easiest to download the installs from the Microsoft website or just run it from the Exchange server itself.

  2. Pingback: [EXCHANGE 2007] Hide disabled users from GAL

Leave a Reply

Your email address will not be published.