Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Variables in PowerShell Get-WmiObject Filters

$
0
0

Hello,

Can someone please tell me the most efficient way of dealing with this problem. I'm trying to use a variable within a WMI filter and don't know how to deal with the inverted commas.

I am trying to do something along the lines of:

Powershell
Get-WmiObject-ClassWin32_Service-Filter'name="$service.name"'

but obviously the outer single quotes render the inner double quotes obsolete (i.e. the variable won't be expanded) The variables are imported from a CSV file so I don't have much room to manoeuvre.

I don't want to pipe to Where-Object as this line will be used in a foreach loop and I'd like to minimalise performance impact if possible.

Thanks in advance,

Mike


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>