原文地址:http://jacksuper.blog.51cto.com/2724857/1373802ios
爲了工做方便,寫了一個腳本用於導出 ESXi 數據信息。ide
$Report = @() $ESXHosts = Get-VMHost ForEach ($ESXHost in $ESXHosts) { $ReportObj = "" | Select "ESXi 主機名", "所屬羣集", "VMKernel IP", "ESXi 全版本", "ESXi 主版本", "ESXi 子版本", "許可證序號", "許可證版本", "UUID", "製造商", "型號", "BIOS 版本", "BIOS 發佈日期", "設備序列號", "電源狀態", "鏈接狀態", "最後一次啓動時間", "vMotion 啓用狀態", "FaultTolerance 啓用狀態", "CPU 型號", "CPU 插槽數", "每 CPU 內核數", "物理 CPU 內核數", "邏輯 CPU 內核數", "超線程啓用狀態", "每 CPU 速度(MHz)", "CPU 總速度(MHz)", "CPU 已用速度(MHz)", "內存總容量 GB", "內存使用量 GB", "網卡數", "HBA 卡數", "備註" $ESXHost_Temp = ($ESXHost | Get-View) $ESXHost_SerialNumber=Get-EsxCli -VMHost $ESXHost $ReportObj."ESXi 主機名" = $ESXHost.Name $ReportObj."所屬羣集" = $ESXHost.Parent $ReportObj."ESXi 主版本" = $ESXHost.Version $ReportObj."ESXi 子版本" = $ESXHost.Build $ReportObj."許可證序號" = $ESXHost.LicenseKey $ReportObj."製造商" = $ESXHost.Manufacturer $ReportObj."型號" = $ESXHost.Model $ReportObj."電源狀態" = $ESXHost.PowerState $ReportObj."鏈接狀態" = $ESXHost.ConnectionState $ReportObj."CPU 型號" = $ESXHost.ProcessorType $ReportObj."物理 CPU 內核數" = $ESXHost.NumCpu $ReportObj."超線程啓用狀態" = $ESXHost.HyperthreadingActive $ReportObj."CPU 總速度(MHz)" = $ESXHost.CpuTotalMhz $ReportObj."CPU 已用速度(MHz)" = $ESXHost.CpuUsageMhz $ReportObj."內存總容量 GB" = [math]::round($ESXHost.MemoryTotalGB, 0) $ReportObj."內存使用量 GB" = [math]::round($ESXHost.MemoryUsageGB, 0) $ReportObj."VMKernel IP" = $ESXHost_Temp.Config.Option | ?{$_.Key -like "Vpx.Vpxa.config.vpxa.hostIp"} | % {$_.Value} $ReportObj."ESXi 全版本" = $ESXHost_Temp.Config.Product.FullName $ReportObj."許可證版本" = $ESXHost_Temp.Config.Product.LicenseProductVersion $ReportObj."UUID" = $ESXHost_Temp.Summary.Hardware.Uuid $ReportObj."BIOS 版本" = $ESXHost_Temp.Hardware.BiosInfo.BiosVersion $ReportObj."BIOS 發佈日期" = $ESXHost_Temp.Hardware.BiosInfo.ReleaseDate $ReportObj."最後一次啓動時間" = $ESXHost_Temp.Summary.Runtime.BootTime $ReportObj."vMotion 啓用狀態" = $ESXHost_Temp.Summary.Config.VmotionEnabled $ReportObj."FaultTolerance 啓用狀態" = $ESXHost_Temp.Summary.Config.FaultToleranceEnabled $ReportObj."CPU 插槽數" = $ESXHost_Temp.Summary.Hardware.NumCpuPkgs $ReportObj."每 CPU 內核數" = ($ESXHost.NumCpu / $ESXHost_Temp.Summary.Hardware.NumCpuPkgs) $ReportObj."邏輯 CPU 內核數" = $ESXHost_Temp.Summary.Hardware.NumCpuThreads $ReportObj."每 CPU 速度(MHz)" = $ESXHost_Temp.Summary.Hardware.CpuMhz $ReportObj."網卡數" = $ESXHost_Temp.Summary.Hardware.NumNics $ReportObj."HBA 卡數" = $ESXHost_Temp.Summary.Hardware.NumHBAs $ReportObj."設備序列號" = $ESXHost_SerialNumber.hardware.platform.get().SerialNumber $ReportObj."備註" = "" $Report += $ReportObj } $Report | Export-Csv -NoTypeInformation -Encoding UTF8 -path Esxi-Host-Info.csv