Link to home
Start Free TrialLog in
Avatar of ndalmolin_13
ndalmolin_13Flag for United States of America

asked on

Help using test-path to check for the existence of a registry key in Powershell

Hello All,

I'm trying to test for the existence of a registry key using the test-path command.  Here is what I'm doing:
test-path -Path 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F66F74D4-ACF1-48EE-BF6F-2C6629581859}'

I know for a fact this exists, but the test-path is coming up as "False".

Any help would be appreciated.

Thanks,
Nick
ASKER CERTIFIED SOLUTION
Avatar of Seth Simmons
Seth Simmons
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note - you can actually use the full path as in regedit if you prepend it with "registry::", for example:
test-path -Path 'registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F66F74D4-ACF1-48EE-BF6F-2C6629581859}'

Open in new window


Or if you're already in the registry drive, so that the cmdlet knows to use the registry provider, your original command will work.
cd hklm:\
test-path -Path 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F66F74D4-ACF1-48EE-BF6F-2C6629581859}'

Open in new window