I am using Windows 10 20H2, I have successfully recreated this problem multiple times without failure, on PowerShell Desktop 5.1.19041.610 and PowerShell Core 7.1.1.
The problem: Test-Path only works with two PowerShell registry drives(shortened registry hive names):
HKCU:
and HKLM:
They are abbreviations of HKEY_CURRENT_USER
and HKEY_LOCAL_MACHINE
respectively.
In PowerShell the full names of them are:
Registry::HKEY_CURRENT_USER
and Registry::HKEY_LOCAL_MACHINE
respectively.
However there are five registry hives, the other three being:
HKEY_CLASSES_ROOT
, HKEY_CURRENT_CONFIG
and HKEY_USERS
Their shortnames:
HKCR:
, HKCC:
and HKU:
Test-Path
can't find the drives, however Test-Path
can find them if full names are supplied:
TEST-PATH HKCR:
TEST-PATH HKCU:
TEST-PATH HKLM:
TEST-PATH HKU:
TEST-PATH HKCC:
TEST-PATH REGISTRY::HKEY_CLASSES_ROOT
TEST-PATH REGISTRY::HKEY_CURRENT_CONFIG
TEST-PATH REGISTRY::HKEY_USERS
$PSVersionTable
I am curious and I want to know why it behaves like this.
Can anyone offer an explanation?
I have confirmed the other three drives also don't work with other cmdlets, how can I use the three registry drives?