AzSynapsePipelineLastExecution.psm1
<#
.SYNOPSIS This command provides the list of pipelines and the corresponding last execution Pipelinerun details of the same within Azure Synapse. .DESCRIPTION This command provides the list of pipelines and the corresponding last execution Pipelinerun details of the same within Azure Synapse. .PARAMETER WorkspaceName The name of the WorkspaceName. .PARAMETER PipelineName The name of the Pipeline in the DataFactory V2. .EXAMPLE Get-AzSynapsePipelineLastExecution -WorkspaceName"<<WorkspaceName>>" Get-AzSynapsePipelineLastExecution -WorkspaceName "<<WorkspaceName>>" -PipelineName "<<PipelineName>>" -$StartRange "<<StartRange>>" -$EndRange "<<EndRange>>" #> Function Get-AzSynapsePipelineLastExecution { Param ( [Parameter(Mandatory=$true)] [string] $WorkspaceName , [Parameter(Mandatory=$false)] [string] $PipelineName, [datetime]$StartRange = "1900-01-01", [datetime]$EndRange = (Get-Date).ToString() ) $resultarray = @() if (!$PipelineName) { $Pipelines=Get-AzSynapsePipeline -WorkspaceName $WorkspaceName for($j=0; $j -lt $Pipelines.Length; $j++) { $PipelineRuns=Get-AzSynapsePipelineRun -WorkspaceName $WorkspaceName -RunStartedAfter $StartRange -RunStartedBefore $EndRange -PipelineName $Pipelines[$j].Name if ($PipelineRuns) ## if there are no runs for that pipeline skip { $resultarray=$resultarray + $PipelineRuns[[Array]::IndexOf($PipelineRuns.RunStart,($PipelineRuns | Measure-Object -Property RunStart -Maximum).Maximum)] } } $resultarray |format-table -Property PipelineName,RunId,RunStart,RunEnd,DurationInMs,Status,Message -AutoSize } #endif else { $PipelineRuns=Get-AzSynapsePipelineRun -WorkspaceName $WorkspaceName -RunStartedAfter $StartRange -RunStartedBefore $EndRange -PipelineName $PipelineName if ($PipelineRuns) ## if there are no runs for that pipeline skip { $PipelineRuns[[Array]::IndexOf($PipelineRuns.RunStart,($PipelineRuns | Measure-Object -Property RunStart -Maximum).Maximum)] |format-table -Property PipelineName,RunId,RunStart,RunEnd,DurationInMs,Status,Message -AutoSize } }#endelse } Export-ModuleMember -Function Get-AzSynapsePipelineLastExecution |