如何在Get-WmiObject Win32_Directory -filter中使用NOT LIKE

时间:2013-09-11 16:01:21

标签: wmi powershell-v3.0

使用Powershell 3.0我试图利用以下命令行的“-filter”选项来过滤掉我不想扫描的目录,当我试图通过WMI远程拉出目录列表时。

LIKE选项工作正常,但我无法弄清楚什么对NOT LIKE有效。我试过了!LIKE,NL,&不喜欢。到目前为止,powershell并不喜欢......

Get-WmiObject Win32_Directory -ComputerName "." -filter "name NOT LIKE '%oracle%'" | select name

让我在这里说清楚。我知道WHERE选项将完成此操作,但该选项最终扫描所有内容,它只是不显示您过滤掉的内容。

1 个答案:

答案 0 :(得分:14)

我找了几个,但我终于明白了。

Get-WmiObject Win32_Directory -ComputerName "." -filter "NOT name LIKE '%oracle%'" | select name