I wanted to export logic app which are associated with ISE(Integration Service Environment). But the below snippet is not working as expect.
$SubscriptionId = ""
$ISEName = "" # Replace with your ISE name
$outputFilePath = "C:\Logic\DevISELogicApps.csv" # Specify your desired output file path
Connect to Azure
Connect-AzAccount
Set-AzContext -SubscriptionId $SubscriptionId
Create an array to hold the Logic App details
$logicAppsList = @()
Get all Resource Groups in the subscription
$resourceGroups = Get-AzResourceGroup
foreach ($rg in $resourceGroups) {
# Get all Logic Apps in the current Resource Group
$logicApps = Get-AzResource -ResourceGroupName $rg.ResourceGroupName -ResourceType "Microsoft.Logic/workflows"
foreach ($logicApp in $logicApps) {
# Get Logic App details to check ISE association
$logicAppDetails = Get-AzLogicApp -ResourceGroupName $rg.ResourceGroupName -Name $logicApp.Name
# Filter Logic Apps deployed in the specified ISE
if ($logicAppDetails.IntegrationServiceEnvironment -and $logicAppDetails.IntegrationServiceEnvironment.Name -eq $ISEName) {
# Add to the list if it matches the ISE
$logicAppsList += [pscustomobject]@{
LogicAppName = $logicApp.Name
ResourceGroup = $rg.ResourceGroupName
ISEEnvironment = $ISEName
}
}
}
}
Export the results to CSV
$logicAppsList | Export-Csv -Path $outputFilePath -NoTypeInformation -Encoding UTF8
Write-Output "Export completed. File saved at $outputFilePath"