In my previous postsabout how to manage iSCSI targets with PowerCLI part 1 and part 2. I used the following line to return the iSCSI adapter:
$hba = $esx | Get-VMHostHba -Type iScsi
But when I used this line against a vSphere 4.1 update 1 host with Broadcom BCM5709 (Dell Poweredge R710). vSphere will use these adapters as Broadcom iSCSI Adapters. And when you run the $hba = $esx | Get-VMHostHba -Type iScsi one-liner, it will return all the vmhba adapters.
[vSphere PowerCLI] C:\> $esx | Get-VMHostHba -Type iScsi
Device Type Model Status
—— —- —– ——
vmhba32 IScsi Broadcom iSCSI Adapter unbound
vmhba33 IScsi Broadcom iSCSI Adapter unbound
vmhba34 IScsi Broadcom iSCSI Adapter unbound
vmhba35 IScsi Broadcom iSCSI Adapter unbound
vmhba37 IScsi iSCSI Software Adapter online
This “problem” can easily be resolved with a Where statement. In the following Where statement you look for a Model that equals “iSCSI Software Adapter”. There is only one Software adapter in ESX(i) so it will return the right vmhba. The PowerCLI line will look like this:
$esx | Get-VMHostHba -Type iScsi | Where {$_.Model -eq "iSCSI Software Adapter"}
[vSphere PowerCLI] C:\> $esx | Get-VMHostHba -Type iScsi | Where {$_.Model -eq "iSCSI Software Adapter"}
Device Type Model Status
—— —- —– ——
vmhba37 IScsi iSCSI Software Adapter online
So the bottom line. Test your code on different setups and update it when necessary 😉