Powershell WMI ROOT\MicrosoftExchangev2, and WQL where usage

自闭症网瘾萝莉.ら 提交于 2019-12-13 02:55:44

问题


(PS Version 1)

PS C:\> $query = 'Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%"'
PS C:\> $query
Select * From Exchange_PublicFolder WHERE Path LIKE "/Foo%"
PS C:\> gwmi -namespace ROOT\MicrosoftExchangev2 -query $query
Get-WmiObject : Provider is not capable of the attempted operation
At line:1 char:5
+ gwmi  <<<< -namespace ROOT\MicrosoftExchangev2 -query $query

It makes no difference if I try to assign the query to a variable first or not. Is there might be a problem with the WQL keyword WHERE? I can run a query without it just fine:

PS C:\> (gwmi -namespace ROOT\MicrosoftExchangev2 -query  "Select * From Exchange_PublicFolder").count
711

It wouldn't be a huge deal to filter later in the pipeline, but I'm trying to figure out what I'm doing wrong here :)


回答1:


I don't think you're doing something wrong, it's just that the provider is not capable of processing your query (as the error states). It seems that using LIKE against any property is not supported, you can use "=" but it's not what you're looking for :(. IMO, using Where-Object is the way to go in this case.



来源:https://stackoverflow.com/questions/580133/powershell-wmi-root-microsoftexchangev2-and-wql-where-usage

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