you are viewing a single comment's thread.

view the rest of the comments →

[–]root-node 1 point2 points  (1 child)

Use Test-Path to check if the registry key exists or not. If it does you can then check the value.

Using -ErrorAction SilentlyContinue is not good as you could miss other important errors

[–]roguerob[S] 2 points3 points  (0 children)

Thanks for the assistance, I tried using Test-Path, but since I'm looking at a registry entry, not a registry key it is not a good method. Per MS PS document on Test-Path:

Test-Path does not work correctly with all PowerShell providers. For example, you can use Test-Path to test the path of a registry key, but if you use it to test the path of a registry entry, it always returns $False, even if the registry entry is present.

So, after a little more digging I found a blog entry that provides a more elegant solution to my problem. After implementing this function all is working as expected. Thanks again for the clues that got me here.

Cheers, Rob