Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Why can't I pass a string variable to the -Query parameter when using get-wmiobject ?

$
0
0

shouldn't this work?

$this = "select * from win32_service where name='WinRM'"

Get-WmiObject -Query $this

I need to build a query string by supplying a variable. I've tried various ways to include the varible in the parameter following -Query, but nothing works. Now I'm trying to use the variable to build the string I'd like to use with -Query. Nothing but errors so far, and they aren't helpful error messages.


Viewing all articles
Browse latest Browse all 8583

Trending Articles