首页 > 解决方案 > 如何通过 PowerShell 中的变量引用 $workflow:xx

问题描述

我在 PowerShell 5.1 中使用工作流,需要填充 $workflow:xx 其中 xx 是基于先前查询的动态

$test = @(1,2,3,4)
workflow my-test{
 param(
   $test
 )

$1=1
$2=2

 ForEach -Parallel ($num in $test){
  $workflow:1 #works but not what I need
  $workflow:$num #does not work
  $workflow:${$num} #does not work
  $workflow:${num} #does not work
 }

$2
}

不是我问题的答案,但这是我的工作。

$test = @(1,2,3,4)
workflow my-test{
 param(
   $test
 )

 ForEach -Parallel ($num in $test){
   write-output $num
 }

}

#returns array of all responses
$response = my-test

标签: powershellworkflow

解决方案


推荐阅读