Hi all , i need to do some vSwitch label changing soon . before i commence . I wanted a VI Script to get all the vm IN A CLUSTER and list all the NICS with corresponding MAC addresses and IP addresses. Noting that each VM has two to three NICS.
Cheers
This will give you the MAC address:
Get-VM | select name, @{Name="mac"; expression={foreach($nic in (Get-View $_.ID).guest.net) {$nic.macAddress}}}
and you should be able to get IPAddr with a foreach loop like:
$vm=""
IPAddr
foreach($ip in $_.IPAddress){
$vm.IPAddr = $ip
}
try this
$VMs = get-vmhost | Get-VM foreach ($VM in $VMs){ $VMx = Get-View $VM.ID $HW = $VMx.guest.net foreach ($dev in $HW) { foreach ($ip in $dev.ipaddress) { $dev | select @{Name = "Name"; Expression = {$vm.name}},@{Name = "IP"; Expression = {$ip}}, @{Name = "MAC"; Expression = {$dev.macaddress}} } } }