List all physical QLogic HBA’s driver and firmware information of all your ESXi 4.1/5.0 hosts using PowerCLI 5.0.1

I wanted to know the version of the QLogic HBA driver and firmware of all ESXi hosts. I took the script I used earlier to list all NIC info and edited it. I ended up with this:

$ExportFilePath = “C:\HostHBAsInfo.csv”
$PuttyUser = “root”
$PuttyPwd = “password”
$Plink = “D:\plink.exe”
$PlinkOptions = ” -v -pw $PuttyPwd”
$RCommand0 = “cat /proc/scsi/qla2xxx/“
$ESXHosts = Get-VMHost | Sort Name
$Report = @()
ForEach ($ESXHost in $ESXHosts) {
$pHbas = $ESXHost | Get-VMHostHBA -Type FibreChannel
$x = 3
ForEach ($pHba in $pHbas) {
$Message = “”
$HostInfo = {} | Select HostName,ESXVersion,Cluster,pHba,FCFirmwareVersion,DriverVersion,BIOSVersion,FCODEFirmware,EFIFirmware,FlashFirmware,ISP
$HostInfo.HostName = $ESXHost.Name
$HostInfo.ESXVersion = $ESXHost.Version
$HostInfo.Cluster = (Get-Cluster -VMHost $ESXHost.Name).Name
$HostInfo.pHba = $pHba.Model
Write-Host “Connecting to: ” $ESXHost.Name -ForegroundColor Green
$Command = $Plink + ” ” + $PlinkOptions + ” ” + $PuttyUser + “@” + $ESXHost.Name + ” ” + $RCommand0 + $x
$Message = Invoke-Expression -command $command
$HostInfo.FCFirmwareVersion = ($Message[1] -split “FC Firmware version “)[1]
$HostInfo.DriverVersion = ($Message[1] -split “Driver version “)[1]
$HostInfo.BIOSVersion = ($Message[5] -split “BIOS version “)[1]
$HostInfo.FCODEFirmware = ($Message[6] -split “FCODE version “)[1]
$HostInfo.EFIFirmware = ($Message[7] -split “EFI version “)[1]
$HostInfo.FlashFirmware = ($Message[8] -split “Flash FW version “)[1]
$HostInfo.ISP = ($Message[9] -split “ISP: “)[1]
$Report += $HostInfo
$x++
}
}
$Report = $Report | Sort-Object HostName
IF ($Report -ne “”) {
$Report | Export-Csv $ExportFilePath -NoTypeInformation
}
Invoke-Item $ExportFilePath

Please note the value of $x is the indexed value of your vmhba device. In my example the 2 HBA ports are the 4th and 5th overall storage devices.

To enable/disable the TSM-SSH service on each host, I used the following PowerCLI onliners (Thanks again Alan):

Get-VMHost | Sort Name | Get-VMHostService | Where { $_.Key -eq “TSM-SSH”} | Start-VMHostService

Get-VMHost | Sort Name | Get-VMHostService | Where { $_.Key -eq “TSM-SSH”} | Stop-VMHostService

Advertisements

Update/Change your ESXi hosts DNS IP address settings with PowerCLI

Long time since last blogpost. Reason: Our third child was born. And it runs with higher priority then work related stuff =)

Anyways, moving right along….

During a domain upgrade we introduced 2 new DC’s in our AD domain that will take over the DNS server role from the old DC’s. Hence all servers need to be updated with the new DNS server IP addresses including the ESXi hosts.

This proved to be relatively easy. I updated all ESXi hosts (managed with vCenter Server) with the command:

Get-VMHost | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress [DNS1 IP address],[DNS2 IP address]

Test it first on one server by specifying it:

Get-VMHost -Name [FQDN of ESXi host] | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress [DNS1 IP address],[DNS2 IP address]

You can also change other parameters, like the Domain and SearchDomain

Get-VMHost | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress [DNS1 IP address],[DNS2 IP address] -Domain [Domain name] -SearchDomain [Search domain name]

Easy! PowerCLI FTW!

Reference: https://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/Set-VMHostNetwork.html

%d bloggers like this: