Formatting PowerShell 7 code like Kusto Query Language
An obscure feature that was added to PowerShell in version 7 is the ability to specify the pipe character on the next line similar to the syntax for Kusto Query Language (KQL).
Get-Command -Name Get-Help, Get-Command, Get-Member -PipelineVariable results
| Select-Object -ExpandProperty ParameterSets
| Select-Object -ExpandProperty Parameters
| Where-Object Aliases
| Select-Object -Property @{label='CmdletName';expression={$results.Name}}, Name, Aliases
| Sort-Object -Property CmdletName, Name -Unique
| Format-Table -GroupBy CmdletName
Pasting code in the PowerShell console with pipes at the beginning of lines only works when
using Ctrl+V
.
For more information, see Intrinsic line continuation in the official Microsoft docs for PowerShell.
ยต