PowerShell for Windows Admins

Jun 6 2010   12:47PM GMT

List Registry subkeys

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

We recently looked at reading Registry values. https://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

$HKLM = 2147483650
$key = "SYSTEM\CurrentControlSet\Services"
$reg = [wmiclass]‘\\.\root\default:StdRegprov’
$subkeys = $reg.EnumKey($HKLM, $key)

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

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: