Programmatically listing any Cmdlet or Function Parameters

by Oct 24, 2018

Ever wondered how you can list all properties exposed by a function or cmdlet? Here is how:

Get-Help Get-Service -Parameter * | Select-Object -ExpandProperty name

Get-Help provides a lot of helpful information and meta data about parameters as well. If you’d like to dump only parameters that support pipeline input, here is how:

Get-Help Get-Service -Parameter * | 
Where-Object { $_.pipelineInput.Length -gt 10 } |
Select-Object -Property name, pipelineinput, parameterValue

The “pipelineInput” property exposes the type of pipeline input a parameter accepts. Unfortunately, it contains a localized string, so a good way to differentiate is to take the string length.

The output might look similar to this and lists only the parameters that can accept pipeline input from an upstream command, and the accepted data type:

name         pipelineInput                  parameterValue     
----         -------------                  --------------     
ComputerName True (ByPropertyName)          String[]           
InputObject  True (ByValue)                 ServiceController[]
Name         True (ByPropertyName, ByValue) String[] 

Twitter This Tip! ReTweet this Tip!