AzSynapseIntegrationRuntimeDependencies.psm1

<#
     .SYNOPSIS
         This Command provide the list of Linked Servicess that depend on the Integrationruntime within Synapse.
 
 
 
     .DESCRIPTION
         This function provides the list of Linked Services that depend on the Integrationruntime within Synapse.
 
 
 
     .PARAMETER WorkspaceName
     The WorkspaceName of Synapse
 
 
 
     .PARAMETER IntegrationruntimeName
     The name of the Integrationruntime in Synapse.
 
 
 
     .EXAMPLE
     Get-AzSynapseIntegrationRuntimeDependencies -WorkspaceName "<<WorkspaceName>>"
     Get-AzSynapseIntegrationRuntimeDependencies -WorkspaceName "<<WorkspaceName>>" -IntegrationruntimeName "<<IntegrationruntimeName>>"
 
#>

Function Get-AzSynapseIntegrationRuntimeDependencies
{

 

 

    Param 
    (
    [Parameter(Mandatory=$true)]
    [string] $WorkspaceName ,
    [Parameter(Mandatory=$false)]
    [string] $IntegrationruntimeName 
    )

 


$htDependee = @{}

 

if(!$IntegrationruntimeName)
{
$AllIntegrationruntime=Get-AzSynapseIntegrationruntime -WorkspaceName $WorkspaceName

 

}
else
{
$AllIntegrationruntime=Get-AzSynapseIntegrationruntime -WorkspaceName $WorkspaceName -Name $IntegrationruntimeName
}

 

 

$AllLinkedService=Get-AzSynapseLinkedService -WorkspaceName $WorkspaceName

 

for ($i=0;$i -lt $AllIntegrationruntime.Count ; $i++)
{
$IRDependantObjects=@()
for ($j=0;$j -lt $AllLinkedService.Count ; $j++)
{

 

if($AllLinkedService[$j].Properties.ConnectVia.ReferenceName -eq $AllIntegrationruntime[$i].Name)
  {

  $IRDependantObjects=$IRDependantObjects+$AllLinkedService[$j].Name
  }

 


}

 

 

if($IRDependantObjects.count -ne 0)
    {

  if ($htDependee.ContainsKey($AllIntegrationruntime[$i].Name))
  {

 

       FOREACH($IRDep in $IRDependantObjects){
    if ($htDependee[$AllIntegrationruntime[$i].Name] -notcontains $IRDep) 

 

        {

 

        $htDependee[$AllIntegrationruntime[$i].Name] += $IRDep
        }
     }
}
else{
     FOREACH($IRDep in $IRDependantObjects){
    if ($htDependee[$AllIntegrationruntime[$i].Name] -notcontains $IRDep) 

 

        {

 

        $htDependee[$AllIntegrationruntime[$i].Name] += ,$IRDep
        }
     }

 

}
}
}

 


for ($i=0;$i -lt $AllIntegrationruntime.Count ; $i++)
{

 

if($htDependee.ContainsKey($AllIntegrationruntime[$i].Name))
{

 

write-host  $AllIntegrationruntime[$i].Name 'has' $($htDependee[$AllIntegrationruntime[$i].Name]).Count 'Dependencies'
Write-Host  $AllIntegrationruntime[$i].Name "is used in" $($htDependee[$AllIntegrationruntime[$i].Name]) `n 
}
else
{
write-host $AllIntegrationruntime[$i].Name "has no / 0 Dependency" `n 
}

 

}
}



Export-ModuleMember -Function Get-AzSynapseIntegrationRuntimeDependencies