Skip to content

Instantly share code, notes, and snippets.

@Graham-Beer
Created July 12, 2018 18:32
Show Gist options
  • Save Graham-Beer/167efb1092d04cec406a2b5093bc0785 to your computer and use it in GitHub Desktop.
Save Graham-Beer/167efb1092d04cec406a2b5093bc0785 to your computer and use it in GitHub Desktop.
Discover pipeline parameters on cmdlets
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