Jun 6 2010 12:47PM GMT
Posted by: Richard Siddaway
PowerShell v2, Registry, WMI
List Registry subkeys
Posted by: Richard Siddaway
We recently looked at reading Registry values. http://itknowledgeexchange.techtarget.com/powershell/reading-registry-values/
Before we can do this we need to be able to work out what subkeys are present for a given Registry key. The WMI StdRegProv class gives us a method for doing this – EnumKeys
|
001
002 003 004 005 |
$HKLM = 2147483650
$key = "SYSTEM\CurrentControlSet\Services" $reg = [wmiclass]‘\\.\root\default:StdRegprov’ $subkeys = $reg.EnumKey($HKLM, $key) $subkeys.snames |
Using the HKLM constant and defining a key to investigate we create an instance of StdRegProv and call the EnumKey method. The results are put into the $subkeys variable. The snames property contains the names of the subkeys




