Hide disabled users from the GAL

Welcome Forums General PowerShell Q&A Hide disabled users from the GAL

Viewing 0 reply threads
  • Author
    Posts
    • #6547
      Participant
      Topics: 1562
      Replies: 0
      Points: 1
      Rank: Member

      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!

Viewing 0 reply threads
  • The topic ‘Hide disabled users from the GAL’ is closed to new replies.