Powershell Test-Path fails to find registry entry

powershell

I'm trying to check the registry for the lookback check flag thus:

Test-Path HKLM:\System\CurrentControlSet\Control\Lsa\DisableLoopbackCheck

This always returns $false when in fact the value does actually exist. I've tried -PathType leaf and -PathType Any with the same result.

Anyone got any ideas?

Thanks.

Best Answer

Isn't DisableLoobackCheck a property of HKLM:\System\CurrentControlSet\Control\Lsa?

You can test-path HKLM:\System\CurrentControlSet\Control\Lsa to see if that path exists, but you need to use Get-ItemProperty to inspect the properties the Lsa key.

I think this Test-PathReg script does what you want.