Skip to content

Commit 0d35ebc

Browse files
StartAutomatingStartAutomating
authored andcommitted
Get-PipeScript: Updating Piecemeal Version
1 parent e937cb9 commit 0d35ebc

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Get-PipeScript.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Piecemeal [ 0.3.5 ] : Easy Extensible Plugins for PowerShell
1+
#region Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
22
# Install-Module Piecemeal -Scope CurrentUser
33
# Import-Module Piecemeal -Force
44
# Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1'
@@ -602,11 +602,20 @@ function Get-PipeScript
602602
$params = @{}
603603
$mappedParams = [Ordered]@{} # Create a collection of mapped parameters
604604
# Walk thru each parameter of this command
605-
foreach ($myParam in $paramSet.Parameters) {
605+
:nextParameter foreach ($myParam in $paramSet.Parameters) {
606606
# If the parameter is ValueFromPipeline
607607
if ($myParam.ValueFromPipeline) {
608+
$potentialPSTypeNames = @($myParam.Attributes.PSTypeName) -ne ''
609+
if ($potentialPSTypeNames) {
610+
foreach ($potentialTypeName in $potentialPSTypeNames) {
611+
if ($potentialTypeName -and $InputObject.pstypenames -contains $potentialTypeName) {
612+
$mappedParams[$myParam.Name] = $params[$myParam.Name] = $InputObject
613+
continue nextParameter
614+
}
615+
}
616+
}
608617
# and we have an input object
609-
if ($null -ne $inputObject -and
618+
elseif ($null -ne $inputObject -and
610619
(
611620
# of the exact type
612621
$myParam.ParameterType -eq $inputObject.GetType() -or
@@ -925,5 +934,5 @@ function Get-PipeScript
925934
}
926935
}
927936
}
928-
#endregion Piecemeal [ 0.3.5 ] : Easy Extensible Plugins for PowerShell
937+
#endregion Piecemeal [ 0.3.6 ] : Easy Extensible Plugins for PowerShell
929938

0 commit comments

Comments
 (0)