Created
November 7, 2022 15:27
-
-
Save cveld/57df0c4517a14b5e0243a91a9e32fe58 to your computer and use it in GitHub Desktop.
Export Vwan Topology - all cidrs of underlying vnet connections
This file contains 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
# You can run this script like so: | |
# . .\vwan-topology-export.ps1 -VirtualWanName vwan-platform-prd-weu-001 | select -Property Component, Name, Cidr, Parent, ParentType | ConvertTo-Csv | Set-Content output.csv | |
param( | |
[Parameter(Mandatory=$true)] | |
$VirtualWanName | |
) | |
$vwan = Get-AzVirtualWan -Name $VirtualWanName | |
$vwanresource = Get-AzResource -ResourceId $vwan.id | |
$split = $vwanresource.Properties.virtualHubs[0].Id.split("/") | |
$hub = Get-AzVirtualHub -resourcegroupname $split[4] -name $split[8] | |
New-Object -TypeName PSObject -Property @{ | |
Component = "Hub" | |
Cidr = $hub.AddressPrefix | |
Name = $VirtualWanName | |
} | |
$conn = $hub.VirtualNetworkConnections | |
$conn | ForEach-Object { | |
$vnet = Get-AzResource -ResourceId $_.RemoteVirtualNetwork.Id | |
$vnet.Properties.addressSpace.addressPrefixes | ForEach-Object { | |
New-Object -TypeName PSObject -Property @{ | |
Component = "Vnet" | |
Name = $vnet.Name | |
Cidr = $_ | |
Parent = $VirtualWanName | |
ParentType = "Hub" | |
} | |
} | |
$prop = $vnet.Properties.subnets | |
$prop | ForEach-Object { | |
New-Object -TypeName PSObject -Property @{ | |
Component = "Subnet" | |
Name = $_.Name | |
Parent = $vnet.Name | |
ParentType = "Vnet" | |
Cidr = $_.properties.addressPrefix | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment