首页 文章

PowerShell worklfow问题

提问于
浏览
0

即使我使用$ workflow前缀限定它,我也无法在子范围内访问工作流变量:

workflow Test-3 {
      $services = "w32time", "spooler"
      $name = "Workflow Test"
      write-verbose -Message ("Local count is {0}" -f $services.Count)
     parallel {
       write-verbose -Message "Name in parallel clause is $workflow:name"
       sequence {
         $seqServices = Get-Service -Name $workflow:services
         write-verbose -Message ("Seq count is {0}" -f $seqServices.Count)
       }
     }

}

这就是我在输出中看到的:

VERBOSE:[localhost]:本地计数为2

VERBOSE:[localhost]:并行子句中的名称是

VERBOSE:[localhost]:Seq计数为165

感谢是否有人可以指出输出中的偏差 .

谢谢SJ

1 回答

  • 0

    好吧,我似乎无法在序列块中传递集合 . 我通过创建本地集合来实现它 . 枚举父集合($ workflow:var)有效..

    sequence {
    $seqServices = @()
    foreach($s in $workflow:services){$seqServices += $s}
    #This works now
    $psServices = Get-Service -Name $seqServices
    write-Verbose -Message ("Sequence count is {0}" -f $psServices.Count)
    

    }

    我现在看到了..

    VERBOSE:[localhost]:序列计数为2

相关问题