Using Real Registry Keys

by Dec 1, 2009

In PowerShell, you access registry keys through virtual drives like HKCU: (for HKEY_CURRENT_USER) and HKLM: (representing HKEY_LOCAL_MACHINE). You do not need these drives, though. Use the traditional registry key name and prepend "Registry::" like this to access any valid registry key:

Dir Registry::HKEY_LOCAL_MACHINE\Software

This way, you can easily copy and paste key names from Regedit, and you can also access registry places not covered by the pre-defined virtual drives. The next line will retrieve all registered file extensions:

dir Registry::HKEY_CLASSES_ROOT\.* -name | Sort-Object

Twitter This Tip! ReTweet this Tip!