VMware Cloud Community
cybercoaster1
Contributor
Contributor
Jump to solution

esxcli output driver version with host name

I seem to be stumped on this for some reason. I need to check a driver version (if installed) on all of our hosts. I have a small script with a foreach.  However I need to see what host the driver version is on when I output to CSV.  I made a variable called $VMHostName that gets the host. I tried to combine that with assigned a $output to the $esxcli line below then added $Vmhostname + $output but that didnt work either (I removed that section ) . Any assistance would be appreciated. 

$EsxHosts = Get-VMHost

foreach($EsxHost in $EsxHosts){

  $esxcli = Get-VMHost $EsxHost | Get-EsxCli

    $VMHostName = $esxhost.Name

    $esxcli.software.vib.list() | where "Name" -eq "scsi-aacraid" | export-csv driver.csv

}

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VMHost |

ForEach-Object -Process {

  $esxcli = Get-EsxCli -VMHost $_

  $esxcli.software.vib.list() | where "Name" -eq "scsi-aacraid" |

  select @{N='VMHost';E={$esxcli.VMHost.Name}},Name,Version,CreationDate,InstallDate,Vendor

} | Export-Csv -Path .\driver.csv -UseCulture -NoTypeInformation


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VMHost |

ForEach-Object -Process {

  $esxcli = Get-EsxCli -VMHost $_

  $esxcli.software.vib.list() | where "Name" -eq "scsi-aacraid" |

  select @{N='VMHost';E={$esxcli.VMHost.Name}},Name,Version,CreationDate,InstallDate,Vendor

} | Export-Csv -Path .\driver.csv -UseCulture -NoTypeInformation


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

Reply
0 Kudos
cybercoaster1
Contributor
Contributor
Jump to solution

That works like a champ! Thanks! I was looking at other samples using select. I need to read up more on that some more.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The other issue was that you placed the Export-Csv inside the loop.

For each ESXi node the file would have been overwritten


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

Reply
0 Kudos