hi - is there a way to get a list of vm's and to identify the pNIC that the vm traffic is going through. I am using 'route based on originating port id' for the load balancing method and am interested to see how many vm's are using each of the active physical uplinks on the vswitch
thanks
Your foreach loops were not correct.
Try it perhaps like this
#Define some variables
$vcServer = "xxxxx"
$cluster = "DEV_Cluster"
$esxcred = import-pscredential -Path D:\VMwebsite\Vmware\password\ESX.enc.xml $vccred = import-pscredential -Path D:\VMwebsite\Vmware\password\VCentre.enc.xml $filelocation = "C:\Myscripts\Scripts\VMUplinks.csv" $Report = @() #Connect to vCenter
Connect-VIServer $vcServer -Credential $vccred | Out-Null
#Connect to ESX hosts in cluster
foreach ($esx in Get-Cluster $cluster | Get-VMHost) { Connect-VIServer $esx -Credential $esxCred
#Retrieve the esxcli instances and loop through them
foreach($esxcli in (Get-EsxTop -CounterName netport)) { $NetworkInfo = "" | select-Object HostName , VMName , Uplink
$NetworkInfo.HostName = $esx.Name $NetworkInfo.VMName = $esxcli.ClientName $NetworkInfo.Uplink = $esxcli.TeamUplink $Report += $NetworkInfo
} #Disconnect from ESX host
Disconnect-VIServer $esx.name -Confirm:$false
} $Report | Export-CSV $filelocation
#Disconnect from vCenter
Disconnect-VIServer $vcServer -Confirm:$false | Out-Null
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
if you are using vsphere4 try to use "esxtop" and press "n" to view network-device relations, I can currently not verify - only ESX 3.x around me at the customers' playgrounds and my lab is out of reach. To get a list with correlated NICs is some scripting work then, but maybe there is a PowerCLI-way, too?
Regards
Michael
HI michael thanks for the info - i was aware of the esxtop method too in vsphere - not sur eits the same in VI3. I have been looking for the information using powershell but have been unable to find out how to get it - does anybody in the community know ? Im not sure whether i should be looking at the VM, Host or Network values in order to find it
LucD might have some info on this, which may inspire you... http://www.lucd.info/2010/12/03/hitchhikers-guide-to-get-esxtop-part-1/
/Rubeck
hi rubeck - thats great - i used the information and have tried to put a script together to go through each VM in a cluster and report HostName, VMName and Uplink. WHen running however i get the correct number of VM's and Uplink information, but my Hostnames are all the same (VMLON014) - should be a mic of VMLON013 and VMLON014. Something wrong with the nesting i think - could anyone advise me how to reformat - script attached
Your foreach loops were not correct.
Try it perhaps like this
#Define some variables
$vcServer = "xxxxx"
$cluster = "DEV_Cluster"
$esxcred = import-pscredential -Path D:\VMwebsite\Vmware\password\ESX.enc.xml $vccred = import-pscredential -Path D:\VMwebsite\Vmware\password\VCentre.enc.xml $filelocation = "C:\Myscripts\Scripts\VMUplinks.csv" $Report = @() #Connect to vCenter
Connect-VIServer $vcServer -Credential $vccred | Out-Null
#Connect to ESX hosts in cluster
foreach ($esx in Get-Cluster $cluster | Get-VMHost) { Connect-VIServer $esx -Credential $esxCred
#Retrieve the esxcli instances and loop through them
foreach($esxcli in (Get-EsxTop -CounterName netport)) { $NetworkInfo = "" | select-Object HostName , VMName , Uplink
$NetworkInfo.HostName = $esx.Name $NetworkInfo.VMName = $esxcli.ClientName $NetworkInfo.Uplink = $esxcli.TeamUplink $Report += $NetworkInfo
} #Disconnect from ESX host
Disconnect-VIServer $esx.name -Confirm:$false
} $Report | Export-CSV $filelocation
#Disconnect from vCenter
Disconnect-VIServer $vcServer -Confirm:$false | Out-Null
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
excellent - thanks everybody for the assistance