Powershell -Filter not accepting two conditions

妖精的绣舞 提交于 2019-12-02 11:29:15
$remoteuserlist = Get-WmiObject Win32_UserAccount -filter {LocalAccount = "True" and Name != "Guest"} –computername $PC -verbose
  1. You were mixing WMI syntax and PowerShell syntax
  2. The brackets encompassing the filter were around the other parameters of Get-WmiObject

The WQL "not equal" operator is != or <>.

WQL Operators

If you have a bunch of old VBScript WMI queries laying around you can use the Get-WMIObject -Query param to reuse them.

$remoteuserlist = Get-WmiObject -query "SELECT * FROM Win32_UserAccount WHERE LocalAccount = 'True' and Name != 'Guest'" –computername $PC -verbose

Not groundbreaking but it can help if you don't want to rewrite queries.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!