How can I get virtual network name from Virtual network gateway in Azure. It is not listed as a property.
How can I get virtual network name from Virtual network gateway in Azure. It is not listed as a property.
To get virtual network name from Virtual network gateway
.
Here is the PowerShell command.
$resourceGroupName = "<RG-NAMe>"
$gatewayName = "<Gateway-Name>"
$gateway = Get-AzVirtualNetworkGateway -ResourceGroupName $resourceGroupName -Name $gatewayName
foreach ($ipConfig in $gateway.IpConfigurations) {
$virtualNetworkName = ($ipConfig.Subnet.Id -split '/')[-3]
Write-Output "Virtual Network Name: $virtualNetworkName"
}
Output:
Reference: Get-AzVirtualNetworkGateway