1

I am trying to get a list of Ip's Attached to a NIC. Trying to use

Get-NetIPAddress. Not getting the list . I have one primary and Multiple secondary ips to a nic.Trying a way to get it all. enter image description here

Stanley Gong
  • 11,522
  • 1
  • 8
  • 16
ferj
  • 101
  • 1
  • 7

1 Answers1

0

If you want to get all private IP addresses of a VM, try the PS command below:

$vm = get-azvm -VMName <vm name> -ResourceGroupName <resource Group name>
#get network interface information of vm
$nicRes = Get-AzResource -ResourceId $vm.NetworkProfile.NetworkInterfaces.Id
#get network interface object 
$nic = Get-AzNetworkInterface -name $nicRes.name -ResourceGroupName $nicRes.ResourceGroupName
#read ip configs of this network interface
foreach($ipConfig in $nic.IpConfigurations){
    $ipConfig.PrivateIpAddress
}

My IP configs of NIC: enter image description here

Result: enter image description here

Stanley Gong
  • 11,522
  • 1
  • 8
  • 16