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
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
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<g>).
Hi, I need to do this with PowerCLI not the vCLI or SSH, thanks anyway though.
OK, that was embarrasing. I looked it up<g>.
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.
Unfortunately the esxcfg- commands are not powerCLI commands, I don't think this will work.
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!
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
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: ( , 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
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
That worked, thank you!