Created
July 12, 2018 18:32
-
-
Save Graham-Beer/167efb1092d04cec406a2b5093bc0785 to your computer and use it in GitHub Desktop.
Discover pipeline parameters on cmdlets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter Find-PipelineParameters { | |
param ( | |
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[System.Management.Automation.CommandInfo] $CommandInfo | |
) | |
$commandInfo.Parameters.Values | Where-Object { | |
$parameterAttribute = $_.Attributes | | |
Where-Object { $_ -is [Parameter] } | |
$parameterAttribute.ValueFromPipeline -or $parameterAttribute.ValueFromPipelineByPropertyName | |
} | |
} | |
## Examples ## | |
Find-PipelineParameters -CommandInfo (Get-command get-content) | |
Get-Command Get-Content | Find-PipelineParameters | select Name, ParameterType |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment