Using get-adUser with Multiple Filter items

I am trying to filter on 2 different conditions:

  • disabled accounts
  • description like 'disabled'

This works:

get-adUser -Filter ('description -like "DISABLED*"') -SearchBase ....

and this works:

get-adUser -Filter ({Enabled -ne $true}) -SearchBase

BUT ... this does not:

get-adUser -Filter (('description -like "DISABLED*"') -or {Enabled -ne $true}) -SearchBase

Any ideas/suggestions are appreciated.

Thanks

  • The AD cmdlets are little different. The enabled property really isn't a boolean. Filter it as a string and it should work.

    get-aduser -filter "(description -like 'Disabled*') -Or (Enabled -ne 'True')" -SearchBase $search

  • Thanks Jeffery, That worked!! I will take this lesson under advisement -Filter (condition A) works -Filter (condition B) works does not mean that -Filter (condition A -or condition B) will work ... ;) Thanks for the prompt response