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