What Are We Talking About?
Most of the time PowerShell is pretty clear about what it is doing. The language attempts to be concise but not cryptic. For example, PowerShell commands follow a consistent Verb-Noun naming convention. Parameter names are in plain English and meaningful. I've certainly worked with my share of cryptic languages. Perl anyone? However, that doesn't mean PowerShell isn't without confusion. It can be challenging to keep track of symbols and characters and what they are supposed to do. This is especially true for PowerShell beginners or those coming from other languages where certain characters have different meanings. I thought it would be helpful to write an article or two about special characters in PowerShell. These are typically punctuation marks that have a specific meaning or use-case in PowerShell. And even then, usage will vary based on the situation. Fortunately, PowerShell is very good at figuring out the context of your command. However, you might need a little assistance to make sure PowerShell will use the character the way you expect. Let's start our exploration of PowerShell characters with the question mark (`?`) and see what we learn along the way. ## Alias Option The first place you'll see `?` used is as a PowerShell alias.
PS C:\> gps | ? ws -gt 300mb
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
1991 135 295680 329588 170.27 17104 1 firefox
848 54 349760 313988 14.63 18960 1 firefox
333 63 303696 311308 27.75 27896 1 firefox
3934 289 361772 316200 134.41 23128 1 Grammarly.Desktop
0 0 3244 689172 24.77 4596 0 Memory Compression
2422 95 384656 424268 10.95 23296 1 powershell_ise
1251 175 249252 382596 11.03 16704 1 pwsh
1553 110 395996 373392 46.47 5488 1 Snagit32
Get-Process | Where-Object ws -gt 300mb
Most of the time PowerShell is pretty clear about what it is doing. The language attempts to be concise but not cryptic. For example, PowerShell commands follow a consistent Verb-Noun naming convention. Parameter names are in plain English and meaningful. I've certainly worked with my share of cryptic languages. Perl anyone?
However, that doesn't mean PowerShell isn't without confusion. It can be challenging to keep track of symbols and characters and what they are supposed to do. This is especially true for PowerShell beginners or those coming from other languages where certain characters have different meanings.
I thought it would be helpful to write an article or two about special characters in PowerShell. These are typically punctuation marks that have a specific meaning or use-case in PowerShell. And even then, usage will vary based on the situation. Fortunately, PowerShell is very good at figuring out the context of your command. However, you might need a little assistance to make sure PowerShell will use the character the way you expect.