Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

Get-Help Get-ChildItem -parameter Name

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top