Powershell -Filter 不接受两个条件 [英] Powershell -Filter not accepting two conditions
本文介绍了Powershell -Filter 不接受两个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个命令
$remoteuserlist = Get-WmiObject Win32_UserAccount `
-filter "LocalAccount =True" –computername $PC -verbose
我正在运行以获取机器上的本地帐户列表.我还想从我的列表中排除来宾帐户.所以我尝试了这样的事情
that I am running to get a list of local accounts on a machine. I would also like to exclude the guest account from my list. so I tried something like this
$remoteuserlist = Get-WmiObject Win32_UserAccount `
-filter {LocalAccount =True -and Name -ne "Guest" –computername $PC -verbose}
但我收到无效查询错误.有人能解释一下我大概是非常明显的错误吗?
but I get an invalid query error. Can someone explain my presumably blindingly obvious error?
谢谢
推荐答案
$remoteuserlist = Get-WmiObject Win32_UserAccount -filter {LocalAccount = "True" and Name != "Guest"} –computername $PC -verbose
- 你混合了 WMI 语法和 PowerShell 语法
- 包含过滤器的方括号是
Get-WmiObject
的其他参数
- You were mixing WMI syntax and PowerShell syntax
- The brackets encompassing the filter were around the other parameters of
Get-WmiObject
这篇关于Powershell -Filter 不接受两个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文