I want to save an output to a variable, but it saves more characters than I want to save.
I use:
$InstallLocation1 = Get-WmiObject -Class Win32_Product -Filter 'Name like "%FAS%"' | Select InstallLocation
But then my variable contains:
@{InstallLocation=C:\Program Files\inray\FAS\}
But the content I need is:
C:\Program Files\inray\FAS\
Select-Object(select) by default returns a[pscustomobject]instance that has the requested properties - even when you're only asking for a single property. To get only that property's value, use the-ExpandPropertyparameter instead of the (possibly positionally implied)-Propertyparameter. See the linked duplicate for details and alternatives, notably the ability to simply use(...).SomeProperty