Last week I was giving a PowerShell workshop and asked my students to find all cmdlets with a specific parameter, in this case the “-Like” parameter.
There’s a bunch of ways to do this, but the easiest way we found was the following:
Get-Command | Where-Object { $_.Definition –like “*-list*” }
Now, this will also find commands with a parameter such as “-ArgumentList”… so if we want to exclude those from the result:
Get-Command | Where-Object { ( $_.Definition –like “*-list*” ) –and ( $_.Definition –notlike “*-ArgumentList*” ) }
# find all command with ‘list’ parameter
#> get-help * -param list
Hi Walid2mi,
Although the command you’ve provided is a lot shorter and easier to remember, it also takes quite a bit longer to execute…
Jeff.
hi jeff,
this is my test:
PS> measure-command { get-help * -param list }
–> TotalMilliseconds : 4778,5757
PS> measure-command { Get-Command | Where-Object { $_.Definition –like “*-list*” } }
–> TotalMilliseconds : 893,1512
PS> measure-command { help * -param list }
-> TotalMilliseconds : 403,8105
So, for finding all commands with one specific parameter,the “help * -param list” is easiest and fastest to use.