Get-WmiObject -Class win32_logicaldisk -Filter \'DeviceID=\"C:\"\'
does what I want,
$var=\"C:\"
Get-WmiObject -Class win32_logical
If, for instance, you're getting data from a file with select-string, the return is a single quote string. If that string contains variables they won't expand. Invoke-Expression can be used if the variable is clean - not mixed in with other text:
$abc = 123
$a = '$abc'
iex $a -> 123
If the variable is part of a path name, this doesn't work. Use $ExecutionContext.InvokeCommand.ExpandString($var)
$path = '$Home/HiMum'
$ExecutionContext.InvokeCommand.ExpandString($path)
-> /home/JoeBlogs/HiMum
You lucky sods on Windows might be able to use Convert-String to change singles to doubles.