Powershell – Get Data of Registry Value Saved to a Variable

Question:

I need to save a single data item in a registry key to a variable. I’ve tried the following without any luck:

I want JUST the version number saved to the variable, nothing else. Not the name, just the data.

Thanks in advance for your help!

Answer:

You almost had it. Try:

Get-ItemProperty returns a PSCustomObject with a number of properties — Version among them. This sort of dotted notation as I used above allows you to quickly access the value of any property.

Alternatively, so long as you specify a scalar property, you could use the ExpandProperty parameter of Select-Object:

Source:

Powershell – Get Data of Registry Value Saved to a Variable by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply