EDIT: I changed the code here to a simple test case, rather than a full implementation where this problem occurs.
I am trying to call one Powershell script another, but everything does not work as I expect. As I understand it, the & operator must expand arrays to separate parameters. This is not for me.
caller.ps1
$scriptfile = ".\callee.ps1" $scriptargs = @( "a", "b", "c" ) & $scriptfile $scriptargs
callee.ps1
Param ( [string]$one, [string]$two, [string]$three ) "Parameter one: $one" "Parameter two: $two" "Parameter three: $three"
Running .\caller.ps1 leads to the following output:
Parameter one: abc Parameter two: Parameter three:
I think the problem I'm experiencing is that the $scriptargs not expanded and rather passed as a parameter. I am using PowerShell 2.
How can I get caller.ps1 to run callee.ps1 with an array of arguments?
source share