While retrieving hardware model information from VM Host using Get-VMHostHardware PowerCli cmdlet you may get error “Failed to retrieve CIM memory”
This happens if you are working with ESXi 6.5 or ESXi 6.7 servers and trying to retrieve certain hardware specific information from PowerShell.
Solution:
Use the below mentioned command to retrieve the information.
Get-VMHost | Sort Name | %{$VMHost = $_; $VMHost | Get-View | Select @{N=”make”;E={$_.Summary.Hardware.Vendor}}}
Get-VMHost | Sort Name | %{$VMHost = $_; $VMHost | Get-View | Select @{N=”model”;E={$_.Hardware.SystemInfo.Model}}}
Get-VMHost | Sort Name | %{$VMHost = $_; $VMHost | Get-View | Select @{N=”serial”;E={$_.Hardware.SystemInfo.SerialNumber}}}
Please find below the complete codes
$VMHost = yourESXiHost
Connect-VIServer -Server $vmhost -User “root” -Password “YourESXiRootPassword”
$make = Get-VMHost | Sort Name | %{$VMHost = $_; $VMHost | Get-View | Select @{N=”make”;E={$_.Summary.Hardware.Vendor}}}
write-host $make.make
$model = Get-VMHost | Sort Name | %{$VMHost = $_; $VMHost | Get-View | Select @{N=”model”;E={$_.Hardware.SystemInfo.Model}}}
write-host $model.model
$serialnumber = Get-VMHost | Sort Name | %{$VMHost = $_; $VMHost | Get-View | Select @{N=”serial”;E={$_.Hardware.SystemInfo.SerialNumber}}}
write-host $serialnumber.serial
Disconnect-VIServer -Server * -Force -Confirm:$false