Hide disabled users from the GAL

by mark.graham at 2013-04-17 01:56:35

Hi All,

I am looking to hide all users that are disabled. I have found the following command and when run it gives all users including room mailboxes.

I wanted to filter room mailboxes out of the results if possible and have all the disabled users hidden from the GAL.

I am very new to Powershell and would also like to know for future reference how you put more than one filter into a command.

Get-Mailbox -resultsize unlimited | where {$_.ExchangeUserAccountControl -eq ‘AccountDisabled’} | Set-Mailbox -HiddenFromAddressListsEnabled $true

Thanks in advance.
by nate-n8 at 2013-04-17 06:19:43
get-mailbox -ResultSize unlimited -filter {RecipientTypeDetails -eq ‘UserMailbox’}
by ArtB0514 at 2013-04-17 06:41:21
Another way:
The IsResource property should be true for the room mailboxes and false for the user mailboxes. You can put multiple tests in your filter or where-object clauses. The normal precedence rules apply to put them in the proper order, but I like to use parentheses to make sure that the tests are explicit. Here’s an example:
Get-Mailbox -resultsize unlimited -Filter {((ExchangeUserAccountControl -eq ‘AccountDisabled’) -and (IsResource -eq $false))} | Set-Mailbox -HiddenFromAddressListsEnabled $true
by mark.graham at 2013-04-17 17:34:18
Excellent.

Thank you!