Home > database >  Test-Path Returning false eventhough it exists
Test-Path Returning false eventhough it exists

Time:10-12

Powershell command showing false , even though that path exist in registry, what wrong i am doing?

PS D:\Folder> Test-Path -Path 'HKU:\S-9-9-21-57989841-616249376-1801674531-2451702'
False

enter image description here

CodePudding user response:

Drive HKU: is not defined by default.

Either use:

Test-Path -Path 'Registry::HKEY_USERS\S-9-9-21-57989841-616249376-1801674531-2451702'

or define the drive first:

$null = New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS
Test-Path -Path 'HKU:\S-9-9-21-57989841-616249376-1801674531-2451702'

and when finished remove that drive with Remove-PSDrive -Name HKU

  • Related