Pass multiple arguments/parameters to powershell workflow

1.3k Views Asked by At

I have a powershell workflow script as below:

workflow mytest{
    param($param1,$param2,$param3)
    //code
}

mytest $param1,$param2,$param3

Issue here is all the three params were received as array in $param1.

2

There are 2 best solutions below

0
Nando On

Type your params

Workflow Test-Runbook
{
  Param
  (
   [Parameter(Mandatory=<$True | $False>]
   [Type]$<ParameterName>,

   [Parameter(Mandatory=<$True | $False>]
   [Type]$<ParameterName>
  )
  <Commands>
}

https://learn.microsoft.com/fr-fr/system-center/sma/overview-powershell-workflows?view=sc-sma-2019

0
js2010 On

All you're doing is passing an array to $param1. Powershell parameters always work that way. \\code is not a comment.

workflow mytest{
    param($param1,$param2,$param3)
    "param1 $param1  param2 $param2  param3 $param3"
}

mytest 1 2 3

param1 1  param2 2  param3 3