Read Registry Values

by Mar 31, 2010

You will find that reading Registry values is not always easy because the Registry is accessible only via the generic "drive" paradigm. Here is a function you can use to read registry values:

Function Get-RegistryValue($key, $value) {
Get-ItemProperty "Registry::$key" $value |
Select-Object -expandProperty $value
}

You should use it like this:

Get-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion' ProductID

Twitter This Tip! ReTweet this Tip!