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
}
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
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
That works like a champ! Thanks! I was looking at other samples using select. I need to read up more on that some more.
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