Get current IP addresses associated with an Azure ARM VM's set of NICs via Powershell
I use this code to get all my ARM VMs, their private IP address and allocation method, it works across resource groups.
$vms = get-azurermvm
$nics = get-azurermnetworkinterface | where VirtualMachine -NE $null #skip Nics with no VM
foreach($nic in $nics)
{
$vm = $vms | where-object -Property Id -EQ $nic.VirtualMachine.id
$prv = $nic.IpConfigurations | select-object -ExpandProperty PrivateIpAddress
$alloc = $nic.IpConfigurations | select-object -ExpandProperty PrivateIpAllocationMethod
Write-Output "$($vm.Name) : $prv , $alloc"
}
Sample Output:
proddc : 10.0.0.4 , Static
stagedc : 10.1.0.4 , Static