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).
1Get-Command -Name Get-Help, Get-Command, Get-Member -PipelineVariable results
2| Select-Object -ExpandProperty ParameterSets
3| Select-Object -ExpandProperty Parameters
4| Where-Object Aliases
5| Select-Object -Property @{label='CmdletName';expression={$results.Name}}, Name, Aliases
6| Sort-Object -Property CmdletName, Name -Unique
7| 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.
µ