我正在尝试使用 Powershell 工作流程和一些我需要并行完成的工作来让我的脚湿透。
在遇到第一个障碍之前我没有走多远,但我不明白我在这里做错了什么:
$operations = ,("Item0", "Item1")
ForEach ($operation in $operations) {
Write-Output "Item0: $($operation.Item(0)) Item1: $($operation.Item(1))"
}
workflow operationsWorkflow{
Write-Output "Running Workflow"
$operations = ,("Item0", "Item1")
ForEach -Parallel ($operation in $operations) {
#Fails: Method invocation failed because [System.String] does not contain a method named 'Item'.
#Write-Output "Item0: $($operation.Item(0)) Item1: $($operation.Item(1))"
Write-Output "Item $operation"
}
}
operationsWorkflow