WQL in filter doesn't work

こ雲淡風輕ζ 提交于 2019-12-01 19:58:13

I'm not sure how to make the filter query work as I don't know how to access the array elements to check them, but have a workaround:

Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.DefaultIPGateway -ne $null }

This way, powershell will be responsible for filtering the objects returned from the query, rather than WMI doing it during retrieval.

WQL-queries does not support array-properties.

Note WQL does not support queries of array datatypes.

Source: Querying with WQL @ MSDN

The solution is to filter out the objects with null-value using PowerShell's Where-Object cmdlet.

Get-WmiObject -Class Win32_NetworkAdapterConfiguration |
Where-Object { $_.DefaultIPGateway }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!