Hi LucD,
After digging some post, I got the below code. It fits almost my requirement, it doesn't have vCenter name and it doesn't export to a csv. Please add the vCenter name to the below code and make it exported to csv.
$hostname = Get-View -ViewType HostSystem -property name,Hardware.SystemInfo
foreach ($hname in $hostname)
{
$hn = $hname.name
$Man = $hname.Hardware.SystemInfo.Vendor
$Mod = $hname.Hardware.SystemInfo.Model
$serviceTag = $($hname.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq “ServiceTag” }).IdentifierValue
$hname | Add-Member -MemberType NoteProperty -Name VMHost -Value $hn
$hname | Add-Member -MemberType NoteProperty -Name OEM -Value $Man
$hname | Add-Member -MemberType NoteProperty -Name Model -Value $Mod
$hname | Add-Member -MemberType NoteProperty -Name ServiceTag -Value $serviceTag
}$hostname | select VMHost, OEM, Model, ServiceTag
My actual requirement is to perform a upgrade/maintenance activity during this Christmas time for our all servers. So it would be very helpful to have the list of all servers with detailed information such as
vCentername vCenterUUID Server/hostname ModelNo ServiceTag Warranty ESXiVersionName BIOS AdapterFirmware NetworkDriver FCDriver HBAModel HBADriver HBAModule HBAVersion
I have the below code can this be updated to reflect the above said fields? If the field Warranty is unable to be fetched then that can be skipped as it not required for the upgrade activity but for a later use.
$ResultFile = "C:\temp\Result.CSV"
$vmhosts = Get-Datacenter | Get-VMHost
$report = @()
foreach ( $ESXHost in $vmhosts)
{
$HWModel = Get-VMHost $ESXHost
$esxcli = Get-EsxCli -vmhost $ESXHost
$info = $esxcli.network.nic.get("vmnic0")
$elxnet = $esxcli.software.vib.list() | Where-Object { $_.name -eq "elxnet" }
$lpfc = $esxcli.system.module.list() | Where-Object { $_.Name -eq '*' }
if ($lpfc)
{
$lpfc = $esxcli.system.module.get("*")
}
$report += $ESXHost |
Select-Object @{N = "Hostname"; E = { $_.Name } },
@{N = "IPAddress"; E = { ($_ | Get-VMHostNetwork).VirtualNic | Where-Object { $_.ManagementTrafficEnabled } | Select-Object -ExpandProperty IP } },
Manufacturer,
ProcessorType,
@{N = "BIOS version"; E = { $_.ExtensionData.Hardware.BiosInfo.BiosVersion } },
@{N = "Hardware-Model"; E = { $HWModel.Model } },
@{N = "Adapter-Firmware"; E = { $info.DriverInfo.FirmwareVersion } },
@{N = "Network-Driver"; E = { $info.DriverInfo.Version } },
@{N = "FC-Driver"; E = { $elxnet.version.substring(0, 14) } },
@{N = "HBA Model"; E = { ($_ | get-vmhosthba | select-object -ExpandProperty Model) -join ", " } },
@{N = "Driver"; E = { ($_ | get-vmhosthba | select-object -ExpandProperty Driver) -join ", " } },
@{N = 'HBA-Module'; E = { $lpfc.Module } },
@{N = 'HBA-Version'; E = { $lpfc.Version } }
}
$report | Export-Csv -Path $ResultFile -NoTypeInformation
I also get this below warning as well.
Warning:
PS C:\temp> .\GetEsxinfo.ps1
WARNING:
The Get-EsxCli cmdlet provides a new interface to the ESXCLI functionality.
Use the -V2 parameter to switch to the new cmdlet interface.
Check the cmdlet help for more information.
Scripts that use the old cmdlet interface may not be compatible across two different versions of the ESX server.
The old cmdlet interface is deprecated and will be removed in a future version.
WARNING: The 'VirtualNic' property of VMHostNetworkInfo type is deprecated. Use 'Get-VMHostNetworkAdapter' cmdlet
instead.
My CLI version is 11.5 and all of the components are recently updated.
*****************************************************************************************************************************************
PowerCLI Version
----------------
VMware PowerCLI 11.5.0 build 14912921
---------------
Component Versions
---------------
VMware Common PowerCLI Component 11.5 build 14898112
VMware Cis Core PowerCLI Component PowerCLI Component 11.5 build 14898113
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.5 build 14899560
VMWare ImageBuilder PowerCLI Component 6.7 build 11233116
VMWare AutoDeploy PowerCLI Component 6.7 build 11233116
VMware VimAutomation Vds Commands PowerCLI Component PowerCLI Component 11.2 build 12483615
VMware VimAutomation Cloud PowerCLI Component PowerCLI Component 11.0 build 10379994
VMware High Availability PowerCLI Component 6.0 build 000000
VMware HorizonView PowerCLI Component 7.1.0 build 14653756
VMware VimAutomation License PowerCLI Component PowerCLI Component 11.3 build 13990093
VMware VimAutomation PCloud PowerCLI Component PowerCLI Component 10.0 build 7893924
VMware VimAutomation Storage PowerCLI Component PowerCLI Component 11.5 build 14901686
VMware VimAutomation vROps PowerCLI Component PowerCLI Component 10.0 build 7893921
VMware vSphere Update Manager PowerCLI 6.5 build 7862888
*****************************************************************************************************************************************