Powershell 列出所有不包含特定关键字的已安装应用程序
我目前正在编写一个PowerShell脚本,以生成一个txt文件,其中包含所有已安装应用程序的列表,但不包含某些关键字Powershell 列出所有不包含特定关键字的已安装应用程序,powershell,Powershell,我目前正在编写一个PowerShell脚本,以生成一个txt文件,其中包含所有已安装应用程序的列表,但不包含某些关键字 (Get-WmiObject Win32_Product | where ($_.Vendor -notcontains "Advanced") | Format-List name,Vendor,Version | out-string ).trim() >> AllApps.txt 上面的脚本我想列出供应商在AllApps.txt
(Get-WmiObject Win32_Product |
where ($_.Vendor -notcontains "Advanced") |
Format-List name,Vendor,Version |
out-string
).trim() >> AllApps.txt
上面的脚本我想列出供应商在AllApps.txt中不包含“Advanced”的所有已安装应用程序。但是,它输出所有应用程序,并且脚本中的“-notcontains”不起作用
你能告诉我哪里做错了吗
感谢您提前回复。您需要
-notmatch
而不是-notcontains
Contains/notcontains用于测试对象是否在集合中,例如@(1,2,3)-Contains 2
,而不是用于测试单词是否在字符串中
您还需要在
where{}
code周围使用scriptblock大括号{}
,作为LotPings注释 您需要-notmatch
而不是-notcontains
Contains/notcontains用于测试对象是否在集合中,例如@(1,2,3)-Contains 2
,而不是用于测试单词是否在字符串中
您还需要在
where{}
code周围使用scriptblock大括号{}
,作为LotPings注释 您需要在where对象{$\.Vendor-notcontains“Advanced”}
中使用脚本块,而不仅仅是括号,或者使用简单的where对象Vendor-notcontains“Advanced”
。不要用它来枚举已安装的程序。@LotPings他还需要将{$\.Vendor-notcontains“Advanced”}
更改为{NOT$\.Vendor.Contains(“Advanced”)}
,b/c-Contains
运算符用于数组中的精确匹配,不适用于字符串中的部分匹配。您需要在where对象{$\u.Vendor-notcontains“Advanced”}
中使用脚本块,而不仅仅是括号,或者使用简单形式where对象Vendor-notcontains“Advanced”
。不要用它来枚举已安装的程序。@LotPings他还需要将{$\.Vendor-notcontains“Advanced”}
更改为{-NOT$\.Vendor.Contains(“Advanced”)}
,b/c-Contains
运算符用于数组中的精确匹配,而不是字符串中的部分匹配。