Answer the question
In order to leave comments, you need to log in
How to escape an asterisk in Powershell?
Good day. How to escape an asterisk in Powershell?
I worked with the HKEY_CLASSES_ROOT\*\ registry branch, so he deleted the entire branch from me. I didn't expect such an ambush from Billy.
UPD1: I found an alternative solution for my task, perhaps not the most elegant, but suddenly it will come in handy for someone:
Get-ChildItem HKLM:\Software\classes\ | Where-Object -property PSChildName -eq "*"
UPD2: Get-ChildItem -LiteralPath HKLM:\Software\classes\*
It also works on Set-Item and Set-ItemProperty
UPD3: Long live insanity, a universal solution has been found. An asterisk en route is shielded by two backticks, i.e. ` (not to be confused with apostrophe and quotation marks). For example, New-Item -Path "HKLM:\Software\classes\``*" -Name "test"
Apparently, the first backtick escapes the second and passes through the string filter, and the second, in turn, lets the interpreter know that the asterisk is a regular character, not a wildcard character.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question