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.
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.
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
}