Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

azure - try to get a list of ips attached to the NIC

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

question from:https://stackoverflow.com/questions/65893601/try-to-get-a-list-of-ips-attached-to-the-nic

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...