In PowerShell 2.0 on Win2008R2, if I want to get the same result from a registry key that "REG QUERY" will provide me, as a readable format, the values from a specific registry key, for example:
reg query hkcu\Software\Microsoft\CharMap HKEY_CURRENT_USER\Software\Microsoft\CharMap Advanced REG_DWORD 0x0 CodePage REG_SZ Unicode Font REG_SZ Arial
How can I do this using PowerShell? PowerShell's behavior puzzles me again.
Get-ItemProperty example:
Get-ItemProperty HKCU:\Software\Microsoft\CharMap PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\CharMap PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft PSChildName : CharMap PSDrive : HKCU PSProvider : Microsoft.PowerShell.Core\Registry Advanced : 0 CodePage : Unicode Font : Arial
In my far-fetched example above, I want to see "Advanced", "CodePage" and "Font", but not any PowerShell metadata (names starting with PS). Unfortunately, filtering on the name “PS” will not work for me, because I DO NOT really try to read the settings for the MS Windows character map, I just selected them as a registry key, which is probably for everyone with Windows, so everyone can see how a completely different experience using PowerShell is to look at the registry, compared to the REG.EXE program. There are reasons why someone might want to get only registry values from the registry key without getting any metadata, and anyone who writes tools in PowerShell might want to complete this simple task.
I would like the result to be similar to REG QUERY , but still in its own PowerShell format, and not just flattened to text. I googled and searched everywhere and can't seem to figure it out.
I would like to do this, for example:
$all = GetRealRegistryKeysFrom( HKCU:\Software\Microsoft\CharMap ) for ($item in $all) { ... }
Update . Using the function below works great.
Example Get-RegistryKeyPropertiesAndValues -path HKCU:\Software\.....