View network interfaces and IP for ARM VMs
August 15, 2017
Q. How can I view the network interfaces and IP addresses for an ARM VM using PowerShell?
A. Azure VMs can have multiple network adapters and multiple IP configurations per network adapter which means to view this information there are a few sub-objects we need to examine to get the desired information.
First we need to get a reference to the VM itself. For example:
$vm = Get-AzureRmVM -ResourceGroupName "RG-SCUSA" -Name "DummyVM"
This contains a NetworkProfile which in turn has an array of network interfaces. To look at the first one we could use:
Get-AzureRmResource -ResourceId $vm.NetworkProfile.NetworkInterfaces[0].Id | Get-AzureRmNetworkInterface
We could also get a reference to the NIC, for example:
$vmNIC = Get-AzureRmNetworkInterface | where {$_.Id -eq $vm.NetworkProfile.NetworkInterfaces[0].Id}
The NIC then has an array of IP configurations which have properties such as the private IP address, for example:
PS C:Usersjohn> $vmNIC.IpConfigurations[0].PrivateIpAddress
10.0.0.5
You can experiment looking at the various objects and the attributes to get the exact information you care about.
About the Author
You May Also Like