Q. How can I check to see if a registry key exists in PowerShell?

Keep in mind that the shell maps two drives—HKLM: and HKCU:—to the registry. Using those, you can use the Test-Path cmdlet to see if a key, which will behave more or less like a file system folder, exists.

Don Jones

July 22, 2010

1 Min Read
skeleton keys laid out on white background

Q. How can I check to see if a registry key exists in PowerShell?

A. Keep in mind that the shell maps two drives—HKLM: and HKCU:—to the registry. Using those, you can use the Test-Path cmdlet to see if a key, which will behave more or less like a file system folder, exists.

Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like