forked from Xergy/AzVNetPeers2Csv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAzVNetPeers2csv.ps1
20 lines (14 loc) · 1.01 KB
/
AzVNetPeers2csv.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$Peers_All = Get-AzSubscription |
ForEach-Object { $_ | Set-AzContext |
ForEach-Object { Get-AzVirtualNetwork | Select-Object -property @{N='VirtualNetworkName';E={$_.Name}},ResourceGroupName | Get-AzVirtualNetworkPeering }
}
$Peers_Filtered = $Peers_All |
Select-Object -Property Name, ResourceGroupName, VirtualNetworkName, PeeringState, AllowVirtualNetworkAccess, AllowForwardedTraffic, AllowGatewayTransit, UseRemoteGateways,
@{N='RemoteVNet';E={$_.RemoteVirtualNetwork.id.tostring().split('/')[8]}},
@{N='Subscription';E={
Get-AzSubscription -SubscriptionId ($_.RemoteVirtualNetwork.id.tostring().split('/')[2]) | foreach-object {$_.Name}
}
} |
Select-Object -Property Subscription, ResourceGroupName, VirtualNetworkName, RemoteVNet, Name, PeeringState, AllowVirtualNetworkAccess, AllowForwardedTraffic, AllowGatewayTransit, UseRemoteGateways
$Peers_Filtered | Export-Csv -Path Peers_all.csv -NoTypeInformation
ii Peers_all.csv