All scripts
Azure AI 722

Get-AzureFirewallRuleReport

Exports application and network rule collections from Azure Firewall to a readable table, so a firewall policy that has grown over years stays reviewable.

Get-AzureFirewallRuleReport.ps1
<#
.SYNOPSIS
    Reports Azure Firewall application and network rule collections.

.DESCRIPTION
    Exports every application and network rule collection configured on
    an Azure Firewall, with priority and action, so a firewall policy
    that has grown over years of ad hoc changes stays reviewable in one
    export.

.PARAMETER FirewallName
    Name of the Azure Firewall.

.PARAMETER ResourceGroupName
    Resource group containing the firewall.

.EXAMPLE
    .\Get-AzureFirewallRuleReport.ps1 -FirewallName fw-prod -ResourceGroupName rg-network

.NOTES
    Requires the Az.Network module and an active Connect-AzAccount session.

.AUTHOR
    Shehryar Hassan
#>

param(
    [Parameter(Mandatory)]
    [string]$FirewallName,
    [Parameter(Mandatory)]
    [string]$ResourceGroupName
)

$firewall = Get-AzFirewall -Name $FirewallName -ResourceGroupName $ResourceGroupName

$report = foreach ($collection in $firewall.ApplicationRuleCollections) {
    foreach ($rule in $collection.Rules) {
        [pscustomobject]@{
            CollectionName = $collection.Name
            Priority       = $collection.Priority
            Action         = $collection.Action.Type
            RuleName       = $rule.Name
            TargetFqdns    = $rule.TargetFqdns -join ", "
        }
    }
}

$report | Sort-Object Priority | Format-Table -AutoSize

Read it before you run it, and test in a safe tenant first.