PowerCLI script to get ESXi host driver versions
#### HTML Output Formatting #######
$a = "<style>"
$a = $a + "BODY{background-color:White ;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:Green}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"
################################################################################################
Connect-VIServer vcenter_server
#Remove-Item C:\Temp\DriverInfo.html
$report = @()
$hosts = gc C:\Temp\hosts.txt
forEach ($vihost in $hosts)
{
$gethost = get-vmhost $vihost
$esxcli = $gethost | Get-EsxCli
$row = "" | select ESXiHost,ESXiVendor,Version,Build,ENICVendor,ENIC,FNICVendor,FNIC,LSIVendor,LSI
$row.ESXiHost = $vihost
$row.ESXiVendor = ($gethost | Get-View).Hardware.SystemInfo.Vendor
$row.Version = $gethost.Version
$row.Build = $gethost.Build
$row.ENICVendor = ($esxcli.software.vib.list() | Where { $_.Name -like "nenic"}).Vendor
$row.ENIC = ($esxcli.software.vib.list() | Where { $_.Name -like "nenic"}).Version
$row.FNICVendor = ($esxcli.software.vib.list() | Where { $_.Name -like "nfnic"}).Vendor
$row.FNIC = ($esxcli.software.vib.list() | Where { $_.Name -like "nfnic"}).Version
$row.LSIVendor = ($esxcli.software.vib.list() | Where { $_.Name -like "lsi-mr3"}).Vendor
$row.LSI = ($esxcli.software.vib.list() | Where { $_.Name -like "lsi-mr3"}).Version
$report += $row
}
$report | Sort ESXiHost | ConvertTo-html -Head $a -Body "<H2> </H2>" >> C:\Temp\DriverInfo.html
$body = [System.IO.File]::ReadAllText('C:\Temp\DriverInfo.html')
$text = '<b><font=Arial>NIC Driver version Report</font></b>'
Send-MailMessage -To to@mailaddress.com -From from@mailaddress.com -Subject "Driver version Report" -Body "$text $body" -SmtpServer smtp.mailaddress.com -BodyAsHtml
Disconnect-VIServer vcenter_server -Confirm:$false
No comments:
Post a Comment