How to pass help content to a selection bar in PowerShell?

I just want to find the specific part of the help about some command:

help rd | select-string -pattern 'cmd'

but I only get errors. What's wrong?

+5
source share
2 answers

In ISE, the help function emits MamlCommandHelpInfo objects. The internal help function outputs Get-Help output to the "more" utility (includes help swapping in the console). In ISE, "more" simply writes everything it receives to the pipeline.

To get around this, convert the output to strings. This will work in ISE and in the PowerShell console:

help rd | out-string -stream | select-string cmd
+10
source
help rd | Select-String -Pattern 'cmd'

It works for me. Alternatively try this

help rd | ? {$_ -match 'cmd'}
+3
source

All Articles