VMware Cloud Community
MMAgeek
Enthusiast
Enthusiast
Jump to solution

finding the vmhba number of the software iscsi adapter

Hi, im trying to write some automation scripts but i find on different server models the software iscsi adapter ranges from vmhba32 to vmhba39

Is there a way i can find this number using powercli so i can set it as a variable to use for another command later in the script?

Thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Forgot about the bug with iscsi.

This is the bypass

$esxName = <esxname>
(Get-VmHost $esxName).StorageInfo.ExtensionData.StorageDeviceInfo.HostBusAdapter | where {$_.Model -like "iSCSI Software Adapter" -and $_.Status -notlike "unbound"} | Select Device

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
9 Replies
wdbarker
Enthusiast
Enthusiast
Jump to solution

esxcfg-mpath -l | grep Runtime shows:

ESXiDev:/tmp # esxcfg-mpath -l | grep Runtime

Runtime Name: vmhba32:C0:T0:L0

Runtime Name: vmhba35:C0:T0:L0

Runtime Name: vmhba0:C0:T0:L0

Runtime Name: vmhba37:C0:T0:L0

Runtime Name: vmhba37:C0:T0:L1

Runtime Name: vmhba37:C0:T0:L2

Runtime Name: vmhba33:C0:T0:L0

Is that good enough? (I'm not the grep expert that would grep for the Display Name and back up two lines&lt;g&gt;).

0 Kudos
MMAgeek
Enthusiast
Enthusiast
Jump to solution

Hi, I need to do this with PowerCLI not the vCLI or SSH, thanks anyway though.

0 Kudos
wdbarker
Enthusiast
Enthusiast
Jump to solution

OK, that was embarrasing. I looked it up&lt;g&gt;.

esxcfg-mpath -l | grep -m 1 -B 2 iSCSI | head -n 1 | awk -F ':' '{print $2}'

returns "vmhba37" only. This is on a TSM session. I assume you have basic string handling primitives in the CLI but I could be wrong. I don't use it much.

0 Kudos
MMAgeek
Enthusiast
Enthusiast
Jump to solution

Unfortunately the esxcfg- commands are not powerCLI commands, I don't think this will work.

0 Kudos
wdbarker
Enthusiast
Enthusiast
Jump to solution

Well, mpath commands should be in the PowerCLI. Maybe someone who knows better will chime in. You can always put my command into a script, and call it with Invoke-VMScript. I can't imagine the CLI doesn't include some way to do what you want, but I don't know.

Good luck!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I think you are looking for this

Get-VMHost <hostname> | Get-VMHostHba

And if you only want the HBA name you can do

Get-VMHost <hostname> | Get-VMHostHba | Select Device

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
MMAgeek
Enthusiast
Enthusiast
Jump to solution

Unfortunately that command is giving me an error:

C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-

VMHost wrx-bc-esx01 | Get-VMHostHba

Get-VMHostHba : 05/10/2010 14:39:41 Get-VMHostHba Requested value 'un

bound' was not found.

At line:1 char:40

+ Get-VMHost wrx-bc-esx01 | Get-VMHostHba <<<<

+ CategoryInfo : NotSpecified: (Smiley Happy , ViError

+ FullyQualifiedErrorId : Client20_StorageSerivceImpl_GetVMHostHba_VIError

,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.Storage.GetVMHostHba

The error is documented here http://communities.vmware.com/message/1616472 , along with a workaround but i don't understand how to fix that workaround with my requirements

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Forgot about the bug with iscsi.

This is the bypass

$esxName = <esxname>
(Get-VmHost $esxName).StorageInfo.ExtensionData.StorageDeviceInfo.HostBusAdapter | where {$_.Model -like "iSCSI Software Adapter" -and $_.Status -notlike "unbound"} | Select Device

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
MMAgeek
Enthusiast
Enthusiast
Jump to solution

That worked, thank you!

0 Kudos