Does anyone know why the following command treats the dollar sign as a wildcard instead of a literal:
Get-Alias -Name ?
Is there a way to use an escape character to treat the dollar sign as a literal in the previous command? It causes all aliases that have a name with a single character to be returned instead of only the alias “?” (Where-Object).
Expected behavior would be the same as the following:
Get-Alias | Where-Object Name -eq ?
Just something I ran into and wanted to see what others thought about this.
Even the back ticks work in the new code formatter
Clicking the “Preformatted” button once is all that’s needed which results in “pre]{content}[/pre” being added. I replaced the content including the curly braces with my code. A common mistake might be trying to click the button before and after your code like the old code formatter.
Based on responses from @SystematicADM that I received on Twitter, both of the following work so these are ways to escape the wildcard searching and search for the literal question mark without having to resort to piping to Where-Object.
When you need to escape one of the special characters in the usual “like” wildcards, you can place them in square brackets. (I didn’t know about embedding a backtick in the string as well, which seems to work). You could also use Get-ChildItem on the alias:\ drive, which does have a -LiteralPath parameter: