Looking for a PowerCLI script to get the output of ESXi hosts all the NIC driver and firmware version (ESXi OS 6.0 and 6.5). Script should have ability to capture the host names from a input file and save the output in .csv format with date in file name.
Thanks in advance.
Try something like this
# Input in CSV file
#
# VMHostName
# esx1
# esx2
#
$esxNames = Import-Csv -Path .\hostnames.csv -UseCulture |
select -ExpandProperty VMHostName
Get-VMHost -Name $esxNames -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $_ -V2
$esxcli.network.nic.list.Invoke() |
where{$_.Name -match "^vmnic"} |
ForEach-Object -Process {
$nic = $_
$esxcli.network.nic.get.Invoke(@{nicname=$_.Name}).DriverInfo |
ForEach-Object -Process {
[PSCustomObject]@{
VMHost = $esx.Name
Nic = $nic.Name
Driver = $_.Driver
Version = $_.Version
Firmware = $_.FirmwareVersion
}
}
}
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
# Input in CSV file
#
# VMHostName
# esx1
# esx2
#
$esxNames = Import-Csv -Path .\hostnames.csv -UseCulture |
select -ExpandProperty VMHostName
Get-VMHost -Name $esxNames -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $_ -V2
$esxcli.network.nic.list.Invoke() |
where{$_.Name -match "^vmnic"} |
ForEach-Object -Process {
$nic = $_
$esxcli.network.nic.get.Invoke(@{nicname=$_.Name}).DriverInfo |
ForEach-Object -Process {
[PSCustomObject]@{
VMHost = $esx.Name
Nic = $nic.Name
Driver = $_.Driver
Version = $_.Version
Firmware = $_.FirmwareVersion
}
}
}
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
it is throwing an error here -
Get-VMHost -Name $esxNames -PipelineVariable esx |
Get-VMHost : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is
not null or empty, and then try the command again.
At C:\MVstuff\Network-DriverFW-Check\Network-Driver-FW-version-Check.ps1:4 <file:///C:\MVstuff\Network-DriverFW-Check\Network-Driver-FW-version-Check.ps1:4> char:18
+ Get-VMHost -Name $esxNames -PipelineVariable esx |
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-VMHost], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVMHost
What did you put in the input CSV file?
Did you follow the layout I gave in the comments at the start of the snippet?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LuCD,
Can we able to give the input to fetch the host details from the vCenter server? Please help to suggest
thank you
Regards
Narayanan.
narayan,
change the below lines:
Get-VMHost -Name $esxNames -PipelineVariable esx |
into:
Get-VMHost -PipelineVariable esx |
Hi Lucd,
How can we add description of the nic which shows us the model name of the nics
Try something like this
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference