Jump to content

Hide Disabled accounts from Exchange GAL


Recommended Posts

Posted

Hi,

 

I have made up the following script to do the above. It finds the users i want to perform the action on but itsnt hiding the users from the GAL.

 

Any ideas please?

 

Thanks

 

# Query Options #
$searchRoot = "school.local/School Users/school/Students" # Where to begin your recursive search - If you use top-level (e.g. "domain.local/") make sure to have a trailing slash, otherwise do not use a slash (e.g. "domain.local/Users")
$inactiveDays = 80 # Integer for number of days of inactivity (e.q. 90)

######################

# 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"

$inactiveUsers = get-qaduser -SearchRoot $searchRoot -disabled -NotMemberof "No Auto Disable" -NotLoggedOnFor $inactiveDays -anr "SMTP:*" -ldapfilter "(!(msExchHideFromAddressLists=*))" -sizelimit 0 | select samaccountname

foreach($user in $inactiveUsers){
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...