Created
September 20, 2023 18:07
-
-
Save joshfinley/27a9734852211ac6b3fd5ab62d9a9f5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialize an empty array to hold firewall information | |
$allFirewalls = @() | |
# Get all subscriptions in the tenant | |
$subscriptions = Get-AzSubscription | |
# Loop through each subscription to gather Azure Firewall information | |
foreach ($subscription in $subscriptions) { | |
# Select the subscription for the Azure context | |
Set-AzContext -Subscription $subscription.Id | |
Write-Host "Checking subscription $($subscription.Name) for Azure Firewalls..." | |
# Get Azure Firewalls in the current subscription | |
$firewalls = Get-AzFirewall | |
# Loop through each firewall and gather necessary information | |
foreach ($firewall in $firewalls) { | |
$firewallInfo = [PSCustomObject]@{ | |
SubscriptionName = $subscription.Name | |
SubscriptionId = $subscription.Id | |
FirewallName = $firewall.Name | |
ResourceGroup = $firewall.ResourceGroupName | |
Location = $firewall.Location | |
} | |
$allFirewalls += $firewallInfo | |
} | |
} | |
# Display the Azure Firewalls | |
$allFirewalls | Format-Table -AutoSize | |
# Optionally, you can export this data to a CSV file | |
# $allFirewalls | Export-Csv -Path 'AzureFirewalls.csv' -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment