VMware Cloud Community
Jattman
Contributor
Contributor
Jump to solution

Lookup esxi host ipv6 IP with PowerCLI

Hello all,

In our environment, Esxi host's management IP vmk0 is IPV6 and VMK01 is ipv4.  I would like to list all the vmk0 IPV6 IPs with powercli, have tried the following but it only returns v4 IPs for vmk1 and vmk0 is blank.   

need liek your help with the command or script that can list the IPV6 IPs. Thanks

Get-VMHost my-esxi-host01 | Sort Name | Get-View | Select Name,

@{N="IP Address";E={($_.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}}

Get-VMHost my-esxi-host01  | Sort Name | Get-View | Select Name,

@{N="IP Address";E={$_|Get-VMHostNetworkAdapter -Name vmk0 | Select -ExpandProperty IP}}

1 Solution

Accepted Solutions
jpsider
Expert
Expert
Jump to solution

Get-VMHostNetworkAdapter | where name -eq "vmk0" | select vmhost,name,ipv6

You don't need the get-vmhost at the beginning if you are connected to a vCenter with all hosts.

View solution in original post

5 Replies
jpsider
Expert
Expert
Jump to solution

What about something like this:

Get-VMHostNetworkAdapter | select name,ipv6

Jattman
Contributor
Contributor
Jump to solution

Thank you jpsider, for quick reply and your help.

I tried the command you suggested and  worked and gives IPV6 info.

i have one more question, how can i eliminate the empty vnics and only get results for vmk0 & vmk1 or just vmk0

C:\> Get-VMHost | Get-VMHostNetworkAdapter | select vmhost,name,ipv6

VMHost                             Name               ipv6                                                    

------                                                                                                                                                      

testhost-0101                     vmnic0                                                                                                             

testhost-0101                     vmnic1                                                                                                             

testhost-0101                     vmnic2                                                                                                             

testhost-0101                     vmnic3                                                                                                             

testhost-0101                     vmnic4                                                                                                             

testhost-0101                     vmnic5                                                             

testhost-0101                     vmk0                {fe80::225:b4ff:fe30:9a00/64, abcd:1234:xyx:1234::1:1/64}

testhost-0101                     vmk1                {fe80::250:56ff:fe6b:da65/64}

0 Kudos
jpsider
Expert
Expert
Jump to solution

Get-VMHostNetworkAdapter | where name -eq "vmk0" | select name,ipv6

jpsider
Expert
Expert
Jump to solution

Get-VMHostNetworkAdapter | where name -eq "vmk0" | select vmhost,name,ipv6

You don't need the get-vmhost at the beginning if you are connected to a vCenter with all hosts.

Jattman
Contributor
Contributor
Jump to solution

Great, That works.

Thanks you so much for your help.