Can Powershell Get-ChildProperty get a list of real registry keys like REG QUERY can without extra noise?

Question:

In PowerShell 2.0 on Win2008R2, if I want to get the same output from a registry key that “REG QUERY” would give me, in as readable a format, with the values from a particular registry key, like this:

How would I do that with PowerShell? The behaviour of PowerShell mystifies me, once again.

Get-ItemProperty example:

In my contrived example above, I want to see “Advanced”, “CodePage” and “Font”, but not any of the PowerShell metadata (names starting in PS). Sadly filtering on the name “PS” would not work for me, because I am not REALLY trying to read the MS Windows Character Map settings, I simply chose them as a registry key that probably everyone with Windows has, so everyone can see how utterly different the experience of using PowerShell is to look at the registry, compared to say the REG.EXE program. There are reasons why anybody might want to get just the registry values from a registry key without getting any of the metadata, and anybody writing tools in PowerShell may want to do this simple task.

I would like output similar to REG QUERY but still in native PowerShell format, not just flattened to text. I’ve googled and searched all over and can’t seem to figure this out.

I’d like to be able to for example do this:

Update Using the function below, works great….

Example Get-RegistryKeyPropertiesAndValues -path HKCU:\Software\.....

Answer:

This is a trick:

The problem is when a property start with PS . Working on this code you can elaborate to exclude these:

… One by one inside the where clause. Or just try using

There a script that do what you need.

update reproduced script here:

Source:

Can Powershell Get-ChildProperty get a list of real registry keys like REG QUERY can without extra noise? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply