Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pipe help content to select-string in PowerShell?

Tags:

powershell

I simply want to find specific part in the help about some command:

help rd | select-string -pattern 'cmd'

but I get nothing but errors. What is wrong?

like image 829
Tar Avatar asked May 29 '12 07:05

Tar


1 Answers

In the ISE, the help function emits MamlCommandHelpInfo objects. Internally, the help function pipes the output of Get-Help to the 'more' utility (enables help paging in the console). In the ISE, 'more' is a simply writes to the pipeline whatever it gets.

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

help rd | out-string -stream | select-string cmd
like image 149
Shay Levy Avatar answered Sep 19 '22 11:09

Shay Levy