如何获取 power shell 中所有容器管道的状态?

How to get status of all container pipeline in power shell?

我在 powershell azure 中编写脚本来获取状态管道。

它return只是SPVB_YIELD_KPI的状态。

如何 return 管道中的所有状态容器(示例 [Get Metadata][ForEach]、... 图片中)?

如果你想获取一个管道中每个 activity 的 运行 详细信息,我们可以使用 PowerShell 命令 Get-AzDataFactoryV2ActivityRun. For more details, please refer to here

例如

#Invoke a pipeline
$RunId = Invoke-AzDataFactoryV2Pipeline `
  -DataFactoryName "<DataFactoryName>" `
  -ResourceGroupName "<ResourceGroupName>" `
  -PipelineName "<pipeLineName>"

# check pipeline status
while ($True) {
    $Run = Get-AzDataFactoryV2PipelineRun `
        -ResourceGroupName "<DataFactoryName>" `
        -DataFactoryName "<pipeLineName>" `
        -PipelineRunId $RunId

    if ($Run) {
        if ($run.Status -ne 'InProgress') {
            Write-Output ("Pipeline run finished. The status is: " +  $Run.Status)
            $Run
            break
        }
        Write-Output "Pipeline is running...status: InProgress"
    }

    Start-Sleep -Seconds 10
} 

#  get the running details of  every activity in the pipeline
Get-AzDataFactoryV2ActivityRun `
        -ResourceGroupName "<DataFactoryName>" `
        -DataFactoryName "<pipeLineName>" `
        -PipelineRunId $RunId `
        -RunStartedAfter (Get-Date).AddMinutes(-30) -RunStartedBefore (Get-Date).AddMinutes(30)