TxLongshot360
Enthusiast
Enthusiast

Streamlining VMNIC Driver, Firmware, and DriverVersion output



Hello,


I'm running a vSphere 5.0 environment and I am trying to find a easy way to show each hosts' NIC Driver, NIC Firmware, and NICDriverVersion number. What I'm needing help on is how to streamline what I have already attempted to write (I am new to this). Currently, I have to list each VMNIC separately in my script. The problem with that is I have to list vmnic 0 thru vmnic12 to cover each different host configurations I have. What I really want to be able to do is skip any pNIC not used, but don't know how to do that. 


Any suggestions on how to better write what I am trying to do would be greatly appreciated!


 Connect-VIServer <vcenter>

  1. Data collected in spreadsheet</div>


get-vmhost | ? { $_.Version -gt 5} | get-esxcli | select @{N="Hostname"; E={$_.system.hostname.get().FullyQualifiedDomainName}},



@{N="NIC_Driver_vmnic0";E={$_.network.nic.get("vmnic0").DriverInfo.Driver}},



#Additional vmnics



@{N="NIC_Driver_vmnic4";E={$_.network.nic.get("vmnic4").DriverInfo.Driver}},



@{N="NIC_Driver_vmnic5";E={$_.network.nic.get("vmnic5").DriverInfo.Driver}},



@{N="NIC_Driver_vmnic6";E={$_.network.nic.get("vmnic6").DriverInfo.Driver}},



@{N="NIC_Driver_vmnic7";E={$_.network.nic.get("vmnic7").DriverInfo.Driver}},



@{N="NIC_Driver_vmnic11";E={$_.network.nic.get("vmnic11").DriverInfo.Driver}},



@{N="NIC_Firmware_vmnic0";E={$_.network.nic.get("vmnic0").DriverInfo.FirmwareVersion}},



@{N="NIC_Firmware_vmnic4";E={$_.network.nic.get("vmnic4").DriverInfo.FirmwareVersion}},



@{N="NIC_Firmware_vmnic5";E={$_.network.nic.get("vmnic5").DriverInfo.FirmwareVersion}},



@{N="NIC_Firmware_vmnic6";E={$_.network.nic.get("vmnic6").DriverInfo.FirmwareVersion}},



@{N="NIC_Firmware_vmnic7";E={$_.network.nic.get("vmnic7").DriverInfo.FirmwareVersion}},



@{N="NIC_Firmware_vmnic11";E={$_.network.nic.get("vmnic11").DriverInfo.FirmwareVersion}},



@{N="NIC_DriverVersion_vmnic0";E={$_.network.nic.get("vmnic0").DriverInfo.Version}},



@{N="NIC_DriverVersion_vminc4";E={$_.network.nic.get("vmnic4").DriverInfo.Version}},



@{N="NIC_DriverVersion_vmnic5";E={$_.network.nic.get("vmnic5").DriverInfo.Version}},



@{N="NIC_DriverVersion_vmnic6";E={$_.network.nic.get("vmnic6").DriverInfo.Version}},



@{N="NIC_DriverVersion_vmnic7";E={$_.network.nic.get("vmnic7").DriverInfo.Version}},



@{N="NIC_DriverVersion_vmnic11";E={$_.network.nic.get("vmnic11").DriverInfo.Version}}|Export-csv -NoTypeInformation -UseCulture -Path c:\Export\Out\NicInfo.csv


1 Reply
kunaludapi
Expert
Expert

$Report = @()
$VMhosts = Get-VMhost | ? { $_.Version -gt 5}
foreach ($vmhost in $vmhosts) {
$esxcli = $VMhost | Get-EsxCli
$UPnics = $esxcli.network.nic.list() | Where-Object {$_.link -eq "Up"}
foreach ($pnic in $UPnics) {
$Nicinfo = "" | Select-Object Name, Pnic, Drivers, FirmwareVersion, DriverVersion
$Nicinfo.Name = $vmhost.name
$Nicinfo.Pnic = $pnic.Name
$Nicinfo.Drivers = $esxcli.network.nic.Get($pnic.Name).Driverinfo.Driver
$Nicinfo.FirmwareVersion = $esxcli.network.nic.Get($pnic.Name).Driverinfo.FirmwareVersion
$Nicinfo.DriverVersion = $esxcli.network.nic.Get($pnic.Name).Driverinfo.Version

$Report += $Nicinfo
}
}
$Report | Export-Csv -NoTypeInformation -UseCulture -Path c:\Export\Out\NicInfo.csv

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".