Hide Disbaled Users From GAL Exchange 2010
Hi,
I wish to create a script that will hide users from the Exchange Address list that are disabled. I have pinched a script and i can seem to get it to work. I dont get any errors. Can anyone spot the problem please?
Thanks
Code:
# Add Quest / Exchange Snaps
Add-PSSnapin Quest.ActiveRoles.ADManagement # Adds Quest "qaduser" commands
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 # Adds Exchange Shell Commands
# Squelches error
$ErrorActionPreference="SilentlyContinue"
$user = get-qaduser -SearchRoot "falinge.int/Staff User Accounts" -disabled -NotMemberof "No Auto Disable" -anr "SMTP:*" -ldapfilter "(!(msExchHideFromAddressLists=*))" -sizelimit 0 | select samaccountname
foreach($name in $user){
set-mailbox -HiddenFromAddressListsEnabled $True -identity $name.samaccountname
}
# 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