Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to filter multiple conditions with Get-ADComputer?

$
0
0

Hello,

The goal is to include all computer objects in an OU, then 'exclude' a few.  How do I exclude multiple computer objects using -Filter as follows:

Get-ADComputer -Filter "SamAccountName -ne 'Comp1$'" -and "SamAccountName -ne 'Comp2$'" -and "SamAccountName -ne 'Comp3$'" -Searchbase "ou=myou,dc=acme,dc=com"

Any combination of brackets/parens I cant see to get to work.  Is this even possible with -Filter on Get-AdComputer?


Thanks for your help! SdeDot


Viewing all articles
Browse latest Browse all 21975

Trending Articles