且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将数组作为参数传递给另一个脚本?

更新时间:2023-11-07 13:56:58

尝试如下所示:

start-job -filepath myscript.ps1 -arg (,$myarr)

-ArgumentList接受参数列表/数组.因此,当您提供-arg $myarr时,就好像您要传递数组的元素作为参数一样.因此,您必须强制PowerShell将其视为单个参数(即数组).

The -ArgumentList takes in a list/array of arguments. So when you give -arg $myarr, it is as though you are passing the elements of the array as the arguments. So you have to force PowerShell to treat it as a single argument which is an array.