Need a script to get serial numbers from my esxi hosts and a few other items
PowerState : PoweredOn
Version : 6.0.0
NumCpu : 12
Cluster : Clustername
MaxEVCMode : intel-haswell
vCenter : vcentername
Name : esxi host name
Build : buildnumber
CpuCoreCountTotal : 12
Model : Hardware model number
MemoryTotalGB : Total memory of esxi host
CpuModel : cpu model
MemoryUsageGB : memory usage at time of report
SerialNumber : esxi host serial number
ConnectionState : Connected
Prior to running this make sure you are up to date on your vmware powercli via
Install-Module -Name VMware.PowerCLI
Import-Module VMware.VimAutomation.Core
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false
Update-Module -Name VMware.PowerCLI
$vcenter = "vcenterhostname"
#Tony Unger
#Requires -Version 5
<#If script fails try to run the following commands
Install-Module -Name VMware.PowerCLI
Import-Module VMware.VimAutomation.Core
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false
Update-Module -Name VMware.PowerCLI
#>
& 'C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1'
$report =@()
Connect-VIServer -Server $vcenter
$vmHosts = get-vmhost | select Name,`
ConnectionState,`
PowerState,`
NumCpu,`
MemoryUsageGB,`
MemoryTotalGB,`
Version,`
Build,`
MaxEVCMode,`
@{N="Cluster";E={ $_.Parent}},`
@{N="vCenter";E={ ($_.uid).split("@")[1].split(":")[0]}}
foreach ($vmHost in $vmHosts) {
$VMHardwareInfo = get-vmhosthardware -vmhost $vmHost.name |select Manufacturer,`
Model,`
SerialNumber,`
CpuModel,`
CpuCoreCountTotal
$ESXiInfo = New-Object -TypeName PSObject -Property @{
Name = $vmHost.name
ConnectionState = $vmHost.ConnectionState
PowerState = $vmHost.PowerState
NumCpu = $vmHost.NumCpu
MemoryUsageGB = $vmHost.MemoryUsageGB
MemoryTotalGB = $vmHost.MemoryTotalGB
Version = $vmHost.Version
Build = $vmHost.Build
MaxEVCMode = $vmHost.MaxEVCMode
Cluster = $vmHost.Cluster
vCenter = $vmHost.vCenter
Model = $VMHardwareInfo.Model
SerialNumber = $VMHardwareInfo.SerialNumber
CpuModel = $VMHardwareInfo.CpuModel
CpuCoreCountTotal = $VMHardwareInfo.CpuCoreCountTotal
}
$report += $ESXiInfo
}
$report | export-csv -path c:\temp\ESXiHardwareInfo.csv -notype