Harkamals
Contributor
Contributor

How to get MAC address for Physical NIC of ESX HOST (vmnic0/vmnic1)

Jump to solution

I could retrieve physical NIC details for ESX HOST server, but MAC is empty...How can i get it ?

Thanks/HKS

$net = Get-VMHostNetwork -VMHost myServer.domain.net

$net | fc

class VMHostNetworkInfoImpl

{

VMKernelGateway = 166.12.113.1

ConsoleGateway = 166.12.113.1

ConsoleGatewayDevice = vswif0

DnsAddress =

[

169.40.0.2

169.40.0.1

]

DnsFromDhcp = False

DnsDhcpDevice =

DomainName = domain.net

HostName = hostname1

SearchDomain =

[

eu.hedani.net

]

PhysicalNic =

[

class PhysicalNicImpl

{

BitRatePerSec = 1000

FullDuplex = True

WakeOnLanSupported =

Id = key-vim.host.PhysicalNic-vmnic0

DeviceName = vmnic0

Mac =

DhcpEnabled = False

IP =

SubnetMask =

}

class PhysicalNicImpl

{

BitRatePerSec = 0

FullDuplex = False

WakeOnLanSupported =

Id = key-vim.host.PhysicalNic-vmnic1

DeviceName = vmnic1

Mac =

DhcpEnabled = False

IP =

SubnetMask =

}

]

VirtualSwitch =

[

class VirtualSwitchImpl

{

Key = key-vim.host.VirtualSwitch-vSwitch0

Name = vSwitch0

NumPorts = 128

NumPortsAvailable = 105

Nic =

[

vmnic1

vmnic0

]

Mtu =

}

class VirtualSwitchImpl

{

Key = key-vim.host.VirtualSwitch-vSwitch1

Name = vSwitch1

NumPorts = 64

NumPortsAvailable = 56

Nic =

Mtu =

}

class VirtualSwitchImpl

{

Key = key-vim.host.VirtualSwitch-vSwitch2

Name = vSwitch2

NumPorts = 64

NumPortsAvailable = 64

Nic =

Mtu =

}

]

ConsoleNic =

[

class HostConsoleVirtualNicImpl

{

PortGroupName = Service_Console_VLAN1

Id = key-vim.host.VirtualNic-vswif0

DeviceName = vswif0

Mac = 00:50:56:4c:1d:3b

DhcpEnabled = False

IP = 111.11.111.11

SubnetMask = 255.255.255.0

}

class HostConsoleVirtualNicImpl

{

PortGroupName = Service_Console_ISOL

Id = key-vim.host.VirtualNic-vswif1

DeviceName = vswif1

Mac = 00:50:56:4d:88:87

DhcpEnabled = False

IP = 10.0.0.241

SubnetMask = 255.255.255.0

}

]

VirtualNic =

[

class HostVMKernelVirtualNicImpl

{

VMotionEnabled = True

PortGroupName = Vmotion_VLAN1

Id = key-vim.host.VirtualNic-portgroup3

DeviceName = portgroup3

Mac = 00:50:56:65:04:56

DhcpEnabled = False

IP = 166.12.113.72

SubnetMask = 255.255.255.0

}

]

}

0 Kudos
1 Solution

Accepted Solutions
esarakaitis
Enthusiast
Enthusiast
get-vmhost | % {(get-view $_.id).config.network.pnic} | select Device, Mac

http://www.vmwarescripting.com

View solution in original post

0 Kudos
5 Replies
bubzie
Contributor
Contributor

why don't you try to add get-view for vmhost, then iterate with for-each property, i.e. Network.Pnic, this will give you VMNIC mac address:

Get-VMHost -name i107|%{(get-view $_.Id).Config.Network.Pnic etc.

0 Kudos
halr9000
Commander
Commander

Interesting that you chose to use Format-Custom in this way. I don't think I've ever seen the cmdlet used before. Smiley Happy It's not a bad way to "dump everything"...thanks for the tip.

Looks like your question was answered though, you were just looking at the wrong object.






[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
Harkamals
Contributor
Contributor

Hi there. Could you help with complete code block..i am new to powershell.

I dumped Get-VMHost |fc ....but MAC is empty for all PNic...any thoughts ?

i class VMHostImpl

{

State = Connected

VMSwapfileDatastoreId =

VMSwapfilePolicy =

CustomFields =

[

class 0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

{

Key = MAC

Value =

}

0 Kudos
esarakaitis
Enthusiast
Enthusiast
get-vmhost | % {(get-view $_.id).config.network.pnic} | select Device, Mac

http://www.vmwarescripting.com

0 Kudos
Harkamals
Contributor
Contributor

ESX3.5 and lower versions do not populate MAC address in VI database, hence it is empty. Does not work for 3.0.2, works for 3.5.

Thanks for help.

0 Kudos