I'm looking for a PS script that will automatically hide all disabled users from the GAL. I ran the below command but it didn't actually hide anything so I'm thinking I must be missing something.
get-mailbox -ResultSize unlimited | where{$_.UserAccountControl -eq "AccountDisabled, NormalAccount" -and $_.RecipientTypeDetails -eq "UserMailbox"} | Set-Mailbox -HiddenFromAddressListsEnabled $True
Thanks in advance.
Best Answer
Try this out (haven't run it myself):
Notes:
#
before the pipe to set-mailbox to comment that part out)