我希望我的域中的所有计算机都已启用,并且拥有2003操作系统,并且计算机的名称不包含' ping,pict,pire' 这是我的,但完全失败了:
Get-ADComputer -filter {(Enabled -eq $True) -and (OperatingSystem -like "*2003*")} -properties OperatingSystem | where {($_.Name -notlike 'PING*') -or ($_.Name -notlike 'PICT*') -or ($_.Name -notlike 'PIRE*')} | Select Name
答案 0 :(得分:4)
您可以在过滤器中使用-notlike
运算符,因此不需要where
语句。请参阅Get-ADComputer reference on technet。
正如我提到的那样,将-or
运算符更改为-and
,我将所有条件都放入过滤器中,结果是:
Get-ADComputer -filter {
Enabled -eq $True -and
OperatingSystem -like '*2003*' -and
Name -notlike 'PING*' -and
Name -notlike 'PICT*' -and
Name -notlike 'PIRE*'
} | Select Name