PowerShell Scripts, Tips, Expert Advices, Forums, and Resources

image rotation

Welcome to PowerShell.com, the educational and community site for Windows PowerShell People. Get a quick overview.


As a Powershell.com member you will have access to:

  • Daily PowerShell tips written by Microsoft MVPs and other leading Windows PowerShell experts
  • Free Windows PowerShell advice and training provided by Microsoft MVPs and other leading Windows PowerShell experts
  • Access to leading Windows PowerShell blogs
  • A free ebook, Mastering PowerShell, written by Microsoft MVP Dr. Tobias Weltner
PowerTip of the Day

Finding and Dumping Registry Key Paths

All PowerShell versions

In a previous tip we illustrated how to convert an internal PowerShell path format to a real path. Here is a use case. This code recursively searches through HKEY_CURRENT_USER and dumps all Registry keys that contain the word “powershell” (simply replace the search word with anything else that you may be looking for):

Get-ChildItem -Path HKCU:\ -Include *PowerShell* -Recurse -ErrorAction SilentlyContinue |
  Select-Object -Property *Path* |
  Out-GridView 

The code outputs all properties that have “Path” in it, and as you will see, Registry keys have two properties that contain the key location: PSPath and PSParentPath. Both use the internal PowerShell path format.

To simply dump the Registry paths for all keys meeting your search criteria, try this:

Get-ChildItem -Path HKCU:\ -Include *PowerShell* -Recurse -ErrorAction SilentlyContinue |
  ForEach-Object {
    Convert-Path -Path $_.PSPath
  }

Twitter This Tip! ReTweet this Tip!

Copyright 2012 PowerShell.com. All rights reserved.