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. 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

 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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: