I am working with PowerShell commands. I want to filter records with one field name description. I successfully filter with one description named "school". My command is:
Get-ADuser -filter {(Description -eq "school")} -Properties * | select *
But I want to filter records with multiple values of description like "school", "college", etc. How will this be possible?
You could use an -or statement:
Get-ADuser -filter {(Description -eq "school") -or (Description -eq "college")} -Properties * | select *
Or you could create an array and filter the results, although this is filtering after the query executes, so it may take longer. It would make sense to try and apply a filter to Get-AdUser before passing it through where-object:
@filter = @("school", "college")
Get-ADuser -Properties * | where-object{@filter -contains $_.Description} | select *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With