简体   繁体   English

Powershell WMI ROOT\MicrosoftExchangev2 和 WQL 在哪里使用

[英]Powershell WMI ROOT\MicrosoftExchangev2, and WQL where usage

(PS Version 1) (PS 版本 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? WQL 关键字 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:)稍后在管道中过滤并不是什么大问题,但我试图找出我在这里做错了什么:)

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.似乎不支持对任何属性使用 LIKE,您可以使用“=”,但这不是您要查找的内容:(。IMO,在这种情况下,使用 Where-Object 是 go 的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM