Yes, it's buried deep inside of the object returned by Get-VMHostNetwork.
PS > Get-VMHost | Get-VMHostNetwork | select -expandProperty PhysicalNic | format-list * BitRatePerSec : 100 FullDuplex : True WakeOnLanSupported : True Id : key-vim.host.PhysicalNic-vmnic0 DeviceName : vmnic0 Mac : 00:c0:9f:3a:64:6a DhcpEnabled : False IP : SubnetMask : BitRatePerSec : 100 FullDuplex : True WakeOnLanSupported : True Id : key-vim.host.PhysicalNic-vmnic0 DeviceName : vmnic0 Mac : 00:c0:9f:3a:56:04 DhcpEnabled : False IP : SubnetMask :
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
How about the flipside - Can I identify a VM if I only have the MAC address?
Something like this should do the trick.
$tgtMAC = "00:50:56:b3:30:38"
$vms = Get-VM
foreach($vm in $vms){
$vmMAC = $vm | Get-NetworkAdapter | select MacAddress
foreach($mac in $vmMAC){
if($mac.MacAddress -eq $tgtMAC) {
Write-Host $vm.Name
}
}
}
halr9000 wrote:PS > Get-VMHost | Get-VMHostNetwork | select -expandProperty PhysicalNic | format-list *
I have two hosts and each has two NICs. I get the following error:
Get-VMHostNetwork : Index was outside the bounds of the array.
At line:1 char:31
+ Get-VMHost | Get-VMHostNetwork <<<< | select -expandProperty PhysicalNic | f
ormat-list *
+ CategoryInfo : NotSpecified: (:) [Get-VMHostNetwork], IndexOutO
fRangeException
+ FullyQualifiedErrorId : System.IndexOutOfRangeException,VMware.VimAutoma
tion.Commands.Host.GetVmHostNetwork
I'm really after getting this information in a decent Xml format that relates the host name to the individual NICs. I've also tried this but it doesn't end up with a relationship between the host and the NICs.
Get-vmHost | %{Get-View $_.id} | %{$_.name $($_.config.network.pnic | %{$_.device, $_.mac})}
I used this follows script, however the results are not as they should be. I do not see a MAC address specified.
Get-VMHost | Get-VMHostNetwork | select -expandProperty PhysicalNic | format-list *
BitRatePerSec : 1000
FullDuplex : True
WakeOnLanSupported : False
Id : key-vim.host.PhysicalNic-vmnic0
VMHostId : HostSystem-host-5509
DeviceName : vmnic0
Mac :
DhcpEnabled : False
IP :
SubnetMask :
Name : vmnic0
BitRatePerSec : 1000
FullDuplex : True
WakeOnLanSupported : False
Id : key-vim.host.PhysicalNic-vmnic3
VMHostId : HostSystem-host-5509
DeviceName : vmnic3
Mac :
DhcpEnabled : False
IP :
SubnetMask :
Name : vmnic3
BitRatePerSec : 1000
FullDuplex : True
WakeOnLanSupported : False
Id : key-vim.host.PhysicalNic-vmnic4
VMHostId : HostSystem-host-5509
DeviceName : vmnic4
Mac :
DhcpEnabled : False
IP :
SubnetMask :
Name : vmnic4
BitRatePerSec : 1000
FullDuplex : True
WakeOnLanSupported : False
Id : key-vim.host.PhysicalNic-vmnic5
VMHostId : HostSystem-host-5509
DeviceName : vmnic5
Mac :
DhcpEnabled : False
IP :
SubnetMask :
Name : vmnic5
BitRatePerSec : 1000
FullDuplex : True
WakeOnLanSupported : False
Id : key-vim.host.PhysicalNic-vmnic0
VMHostId : HostSystem-host-9640
DeviceName : vmnic0
Mac :
DhcpEnabled : False
IP :
SubnetMask :
Name : vmnic0
Strange, the MAC property should be in there.
Which PowerCLI version are you running ?
Can you do a
Get-PowerCLIVersion
____________
Blog: LucD notes
Twitter: lucd22
The MAC can be found without the Tools installed, for the IP addr the Tools need to be installed.
____________
Blog: LucD notes
Twitter: lucd22