Powershell WMI ROOT\MicrosoftExchangev2 和 WQL 用法

发布于 2024-07-14 05:59:12 字数 687 浏览 12 评论 0原文

(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

无论我是否尝试先将查询分配给变量,都没有什么区别。 WQL 关键字 WHERE 是否可能存在问题? 我可以在没有它的情况下运行查询:

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

稍后在管道中进行过滤并不是什么大问题,但我试图找出我在这里做错了什么:)

(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 :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

方觉久 2024-07-21 05:59:12

我不认为您做错了什么,只是提供程序无法处理您的查询(如错误所述)。 似乎不支持对任何属性使用 LIKE,您可以使用“=”,但这不是您正在寻找的:(。
IMO,在这种情况下,使用Where-Object 是可行的方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文