|
385 | 385 | if ([switch], [bool] -contains $paramType) { |
386 | 386 | "`$Parameters.$ParameterName = `$parameters.$ParameterName -match 'true';" |
387 | 387 | } |
| 388 | + if ([psobject], [object],[PSObject[]] -contains $paramType) { |
| 389 | + "`$Parameters.$ParameterName = ConvertFrom-JSON @'" + |
| 390 | + [Environment]::NewLine + |
| 391 | + '${{parameters.$ParameterName}}' + [Environment]::NewLine + "'@" |
| 392 | + } |
388 | 393 | # If the parameter type was a scriptblock |
389 | 394 | if ([ScriptBlock], [ScriptBlock[]] -contains $paramType) { |
390 | 395 | "`$Parameters.$ParameterName = foreach (`$p in `$parameters.$ParameterName){ [ScriptBlock]::Create(`$p) }" |
@@ -470,8 +475,13 @@ try { |
470 | 475 | } else { |
471 | 476 | $out.powershell = "$innerScript" -replace '`\$\{','${' |
472 | 477 | } |
| 478 | + if ($ScriptBlock -and $ScriptBlock.Attributes) { |
| 479 | + if ("$($ScriptBlock.Attributes.ConditionString)") { |
| 480 | + $out.condition = "$($ScriptBlock.Attributes.ConditionString)" |
| 481 | + } |
| 482 | + } |
473 | 483 | $out.name = $Name |
474 | | - $out.displayName = $Name |
| 484 | + $out.displayName = $Name |
475 | 485 | if ($definedParameters) { |
476 | 486 | $out.parameters = $definedParameters |
477 | 487 | } |
@@ -505,6 +515,23 @@ try { |
505 | 515 | } |
506 | 516 | $out.run = "$innerScript" -replace '`\$\{','${' |
507 | 517 | } |
| 518 | + if ($ScriptBlock -and $ScriptBlock.Attributes.Key -ne '') { # If the scriptblock has .Attributes with .Key properties |
| 519 | + foreach ($attr in $ScriptBlock.Attributes) { # each of those attributes |
| 520 | + if ($attr -isnot [Reflection.AssemblyMetadataAttribute]) { continue } |
| 521 | + if ($out.($attr.Key)) { # If it already had the key, use the original case. |
| 522 | + $originalNameCase = |
| 523 | + foreach ($prop in $out.psobject.properties) { |
| 524 | + if ($prop.Name -eq $attr.Key) { |
| 525 | + $prop.Name |
| 526 | + break |
| 527 | + } |
| 528 | + } |
| 529 | + $out.$originalNameCase = $attr.Value |
| 530 | + } else { |
| 531 | + $out.($attr.Key) = $attr.value |
| 532 | + } |
| 533 | + } |
| 534 | + } |
508 | 535 | $out |
509 | 536 | } |
510 | 537 | } |
0 commit comments