I'm new to powershell and azure and need to export all the LocalNetworkGateway information from multiple Resource Groups but also from across multiple Subscriptions.
A contributor has kindly provided me with a script that can output the data from multiple Resource Groups within a single subscription but I need to find a way of doing this across all subscriptions without having to set the subscription context manually for each one and then running the script for each subscription.
I have used the
$azureSubs = Get-AzSubscription
as a way of extracting information across multiple subscriptions that does not require Resource Group Names but I am now stuck. The code below has successfully provided info across RG's but within a single subscription.
$resourceGroups = Get-AzResourceGroup
$resourceGroups.foreach{
Get-AzLocalNetworkGateway -ResourceGroupName $_.ResourceGroupName |
Export-Csv -Path "c:\Azure\LocalNetworkGateway.csv" -Append
}