Passing a registry key with an asterisk to Test-Path Passing a registry key with an asterisk to Test-Path powershell powershell

Passing a registry key with an asterisk to Test-Path


Use the -LiteralPath parameter to prevent globbing/wildcard matching.

-LiteralPath<String[]>

Specifies a path to be tested. Unlike Path, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

Write-Host "Begin"Test-Path -LiteralPath "HKLM:\SOFTWARE\Classes\*\shell\Some shell extension"Write-Host "End"