Private/pipelines/Get-PipelineProcessor.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Get-PipelineProcessor {
    param (
        [Parameter(Mandatory = $true, Position = 0 )]
        [string]$Name,

        [Parameter(Mandatory = $true, Position = 0 )]
        [System.Object[]]$Parameters
    )
    process {
        Get-Command -Name $Name -CommandType Alias | `
            Sort-Object -Property Name | `
            ? { $_.Parameters.Count -gt 0 } | `
            ? {
            $commandParameters = $_.Parameters
            $valid = $true
            $Parameters | % {
                $valid = $valid -and ($commandParameters.ContainsKey($_.Name) -and $commandParameters[$_.Name].ParameterType.Name -eq $_.Type)
            }
            $valid
        }
    }
}