Running the command help firewall | Select-Object Category. The result is one column blank Category.
The strange thing is that the empty rows number represent the amount of rows that help firewall would result without calling piping it to Select-Object
Or I'm trying to filter the output of help firewall to return only rows with Name that starts with "Get". Running help firewall | Where-Object Name -like "Get" just returns nothing.
Why aren't these pipes on help working? They are working perfectly on other commands.
Powershell Version 5.1 and using default windows console.
To complement Zilog80's helpful answer with background information:
Get-Commandhelpreveals thathelpis not a mere alias of theGet-Helpcmdlet, but a (built-in) function (submit$function:helpto see its definition).As you've noticed yourself:
while
Get-Helpoutputs an object ([pscsustomobject]) with properties that reflect help-topic metadata such asCategory, which is then rendered as display text by PowerShell's output-formatting system,the
helpfunction returns strings - a stream of text lines representing the rendered help topic - of necessity.You can observe the difference in output type by piping to the
Get-Membercmdlet (help firewall | Get-Membervs.Get-Help firewall | Get-Member)The purpose of the
helpfunction is to wrapGet-Helpwith interactive paging, to allow convenient navigation through lengthy help topics that don't fit onto a single console (terminal) screen.This paging is provided via an external program (by default,
more.comon Windows, andlesson Unix-like platforms, configurable via$env:PAGER, but only in PowerShell (Core) 7+), and since PowerShell only "speaks text" when communicating with external programs,helpmust send a stream of strings (lines for display) to them, which it does viaOut-String-Stream.Note:
When the external paging programs find that their stdout stream isn't connected to a console (terminal), they take no action other than simply passing the input through (in Unix terms, they then behave like
cat).Hypothetically, the
helpfunction itself could determine this condition and then (a) not pipe to the paging program and (b) relay the object output byGet-Helpas-is.[1] However, determining a command's output target from inside that command, using PowerShell code, may not even be possible.[1] The function actually already takes this action when a custom pager defined via
$env:PAGERis found to be a PowerShell command rather than an external program.