2

On Linux, I often use grep with context to find usage information in man pages. Something like

man ls | grep -e '-a' -A 5

will give me enough context to know what the -a option does.

I think Select-String can do something similar, but I can't seem to pipe in the content of Get-Help, just a Get-Help object. I'd like to do something like

Get-Help Get-ChildItem -Detailed | Select-String -Pattern "-Name" -Context 5

to get information about the -Name usage, but this doesn't seem to work.

What's a good way to do this?

Kris Harper
  • 5,672
  • 8
  • 51
  • 96

2 Answers2

4

As @Lee said, if you want just the help for a parameter, use Get-Help's -Parameter argument. Otherwise, you can use Select-String if you convert the output of Get-Help to an array of strings with Out-String -Stream.

Get-Help Get-ChildItem| Out-String -Stream | Select-String file
Rynant
  • 23,153
  • 5
  • 57
  • 71
2

If you want help on the name parameter you can do:

Get-Help Get-ChildItem -parameter Name

Lee
  • 142,018
  • 20
  • 234
  • 287