Contributor
Contributor

esxcli output driver version with host name

Jump to solution

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

}

0 Kudos
1 Solution

Accepted Solutions
Leadership
Leadership

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

0 Kudos
3 Replies
Leadership
Leadership

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

0 Kudos
Contributor
Contributor

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

0 Kudos
Leadership
Leadership

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

0 Kudos