AzDataFactoryV2Activities.psm1

<#
     .SYNOPSIS
         This command provide the list of pipelines , the list of activities coressponding to the pipelines , the count of the activities per pipeline and count of overall pipelines and overall activities in an Azure Data factory
  
   
  
     .DESCRIPTION
         The function helps to provide the list of pipelines , the list of activities coressponding to the pipelines , the count of the activities per pipeline and count of overall pipelines and overall activities in an Azure Data factory. One can provide the specific pipeline as the parameter if the details pertaining to that specific pipeline is needed.
  
   
  
     .PARAMETER ResourceGroupName
     The resource group containing the DataFactory V2
  
   
  
     .PARAMETER DataFactoryName
     The name of the DataFactory V2.
  
   
  
     .PARAMETER PipelineName
     The name of the Pipeline in the DataFactory V2.
  
   
  
     .EXAMPLE
     Get-AzDataFactoryV2Activities -ResourceGroupName "<<RGName>>" -DataFactoryName "<<ADFV2Name>>"
     Get-AzDataFactoryV2Activities -ResourceGroupName "<<RGName>>" -DataFactoryName "<<ADFV2Name>>" -PipelineName "<<PipelineName>>"
    
#>

Function Get-AzDataFactoryV2Activities
{

 

    Param 
    (
    [Parameter(Mandatory=$true)]
    [string] $ResourceGroupName ,
    [Parameter(Mandatory=$true)]
    [string] $DataFactoryName ,
    [Parameter(Mandatory=$false)]
    [string] $PipelineName 

    )

if (!$PipelineName)
{

 $AllPipelineDataset = Get-AzDataFactoryV2Pipeline -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -ErrorAction Stop
 $PipelineCount = $AllPipelineDataset.Count
 $ActivityCount =0

 Write-Host "Pipelines Count :" $PipelineCount
 
 for ($i=0; $i -lt $PipelineCount ; $i++)
 {
 Write-Host ""   # To add a line break between consecutive pipeline details
 Write-Host "PipelineName :" ($AllPipelineDataset[$i]).Name
 Write-Host "Pipeline Activities :" ($AllPipelineDataset[$i]).Activities.Name
 Write-Host "Pipeline Activities Count :" (($AllPipelineDataset[$i]).Activities.Name).Count

 $ActivityCount= $ActivityCount + (($AllPipelineDataset[$i]).Activities.Name).Count
 
 }
 Write-Host "`nTotal Number of Activities in $DataFactoryName : "  $ActivityCount
}
else
{

$PipelineDataset = Get-AzDataFactoryV2Pipeline -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $PipelineName -ErrorAction Stop

Write-Host "PipelineName :" $PipelineName
Write-Host "Pipeline Activities :" $PipelineDataset.Activities.Name
Write-Host "Pipeline Activities Count :" ($PipelineDataset.Activities.Name).Count

}
 
}


Export-ModuleMember -Function Get-AzDataFactoryV2Activities