VMware Cloud Community
virtualdive
VMware Employee
VMware Employee

HBA Information: PowerCLI

Hello All,

Need help again here please,

Want to extract the below information for the HBA copied to csv and sent out through email.

1. HBA Type

2. Firmware version

3. Driver version

4. BIOS Version

All this information is given in the below command output in bold, but not sure how to get this out through PowerCLI.

# cat /proc/scsi/qla2xxx/1
QLogic PCI to Fibre Channel Host Adapter for QMH2562:
        Firmware version 4.04.09 [Class 2] [Multi-ID] , Driver version 8.02.01-k1-vmw48-4vmw

Host Device Name vmhba1

BIOS version 2.15

Any help would be appreciated.

Regards,

'V'
thevshish.blogspot.in
vExpert-2014-2021
0 Kudos
10 Replies
LucD
Leadership
Leadership

There has been a similar post, see the Get HBA hardware details thread.

But that script uses plink.exe and can hence only be used on ESX servers (not ESXi servers).


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

0 Kudos
virtualdive
VMware Employee
VMware Employee

Thanks Luc,

It does not give the BIOS details actually, also one more thing I wanted to add, the users don't have direct root access. So can this script be modified for that.

cheers!

Regards,

'V'
thevshish.blogspot.in
vExpert-2014-2021
0 Kudos
LucD
Leadership
Leadership

Yes, I noticed that BIOS version was not extracted.

Try this updated version of the script.

$qlR1 = [regex]"QLogic.+for\s(\w+):" 
$qlR2 = [regex]"Firmware version ([\d|\.]+).+Driver version ([\d|\.]+)" 
$qlR3
= [regex]"BIOS version ([\d|\.]+)"
$User
= "<user-account>" $Pswd = "<user-password>" $plink = "<PuTTY-directory>\plink.exe" $plinkoptions = " -v -batch -pw $Pswd" $cmd1 = 'cat /proc/scsi/qla*/*' $remoteCommand = '"' + $cmd1 + '"' $report = @() Get-VmHost | % {         $Computer = $_.Name         $command = $plink + " " + $plinkoptions + " " + $User + "@" + $computer + " " + $remoteCommand         $msg = Invoke-Expression -command $command # Extract the required info from the $msg variable
       $msg | % {                 if($_ -match $qlR1){                         $row = "" | Select ESXname, HBAtype, HBAfirmware, HBAdriver, BIOS                         $row.ESXname = $Computer                         $row.HBAtype = $qlR1.Match($_).Groups[1].Value                 }                 if($_ -match $qlR2){                         $matches = $qlR2.Match($_)                         $row.HBAfirmware = $matches.Groups[1].Value                         $row.HBAdriver = $matches.Groups[2].Value                 }                 if($_ -match $qlR3){                         $matches = $qlR3.Match($_)                         $row.BIOS = $matches.Groups[1].Value                         $report += $row                 }         } } $report

I'm not sure you can query the /proc folder with a user that doesn't have root authority.


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

0 Kudos
Chaz999
Enthusiast
Enthusiast

it nice script, however what if we used Putty instead of plink what switches will need to be used

$plink = "<PuTTY-directory>\putty.exe"

$plinkoptions = " -v -batch -pw $Pswd"

thank you

0 Kudos
LucD
Leadership
Leadership

Afaik, the putty command doesn't have the -batch option.

That is required to suppress all interactive prompts.


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

0 Kudos
Chaz999
Enthusiast
Enthusiast

Thank you Lu,

0 Kudos
Chaz999
Enthusiast
Enthusiast

now i have lab ESX host, i tried  your above script using plink.exe but when i ran it gives me Access Denied message. i ran putty (not plink) and check the credential it works fine.

<Error Message>

Host key fingerprint is:
ssh-rsa 1040 cb:38:59:61:e6:87:5d:af:10:7a:3f:1c:e1:d6:6e:d9
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "root".
Sent password
Password authentication failed
Access denied

alternatively

I also tried to run plink from vSpherePowerCLI e.g. plink <host_ip_address> it prompt me for credential but as soon as i put password i got "Access Denied"

Thanks

0 Kudos
LucD
Leadership
Leadership

Do you have any 'special' characters in the password ?

Try putting the password in single quotes instead of double quotes.


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

0 Kudos
Chaz999
Enthusiast
Enthusiast

Yes i used special character in my password and i also tried with single quotes same issue. but i prefer to have this script work with special character

i also change my password that doesnot conntain any special character, though it doesnot gives any access denied error except below message

Server version: SSH-2.0-dropbear_0.52
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.62
Using Diffie-Hellman with standard group "group1"
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-rsa 1039 f7:02:80:54:ac:ed:7c:0c:31:47:32:af:6a
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "root".
Sent password
Access granted
Opened channel for session
Started a shell/command
Server sent command exit status 0
Disconnected: All channels closed

thank you

0 Kudos
Sivapb
Enthusiast
Enthusiast

HI LUccD

When i running the powercli getting following error

can you help me to resolve this

and we are using different version of 4.X .5.X and different hardware vendor

so i can use same script for all right ?

Invoke-Expression : The '<' operator is reserved for future use.

At C:\Users\user\Desktop\hardware.ps1:15 char:33

+         $msg = Invoke-Expression <<<<  -command $command

    + CategoryInfo          : ParserError: (<:OperatorToken) [Invoke-Expressio

   n], ParseException

    + FullyQualifiedErrorId : RedirectionNotSupported,Microsoft.PowerShell.Com

   mands.InvokeExpressionCommand

Invoke-Expression : The '<' operator is reserved for future use.

At C:\Users\sivaraj.p\Desktop\hardware.ps1:15 char:33

+         $msg = Invoke-Expression <<<<  -command $command

    + CategoryInfo          : ParserError: (<:OperatorToken) [Invoke-Expressio

   n], ParseException

    + FullyQualifiedErrorId : RedirectionNotSupported,Microsoft.PowerShell.Com

   mands.InvokeExpressionCommand

0 Kudos