I am trying to build a report which shows the ESXi Image profile information (the information present in the summary tab of an ESXI host, in the vSphere Client).
I have found that there is a view which shows this information
$hostview = Get-View -viewtype hostsystem
(Get-View -Id $hostview[0].ConfigManager.ImageConfigManager).HostImageConfigGetProfile() | Select * | format-list
However this is a bit slow, and I have a few hundred hosts to report on.
Is there any way I can get All the ConfigManager.ImageConfigManager information for all hosts instead of getting the view of each host?
You'll want to use the Get-VMHost command, then use Select-Object to grab the info you want
Get-VMHost * | Get-View | Select-Object -expandProperty ConfigManager
That will expand all the ConfigManager properties and show you everything per-host. If you just want to see which ConfigManager is applied to each, remove the -expandProperty.
If you need to do this on a per-DataCenter basis, you can prepend the command above with Get-DataCenter [dc-name]
That's not quite what I was looking for.
The ConfigManager will return all of the MoRef-IDs of all the "views" of each host, see below.
You still have to call get-view and then call a method to get the actual profile information.
For example, with 3000 hosts you need to call get-view 3000 times on each of these hosts's ImageConfigManager Moref.
I was wondering if I could get the ImageProfile Information from another object, much like we do get-view -viewtype HostSystem, or any other ConfigManager like object
Try this:
(get-view ((get-vmhost myvmhost.mycompany.com).ExtensionData.ConfigManager.ImageConfigManager)).HostImageConfigGetProfile()
Name : (Updated) Vmware-ESXi-6.0.0-3620759-Custom-Cisco-6.0.2.1
Vendor : Cisco
So, if you wanted to get this for all hosts, you can try something along these lines, report style:
$outObj = foreach ($vmhost in (get-vmhost))
{
$ImageConfigMgr = (get-view ($vmhost.ExtensionData.ConfigManager.ImageConfigManager)).HostImageConfigGetProfile()
New-Object PSObject -Property @{
esxiHost = $vmhost.Name
vCenterCluster = ($vmhost | get-cluster).Name
ImageName = $ImageConfigMgr.Name
ImageVendor = $ImageConfigMgr.Vendor
}
}
Now this is probably the fastest way without getting into native code, but no matter what you will need to do at least one get-view call. I can pull 30 hosts in around a minute, so not bad. You could have this run as a scheduled task then either save the output object as a cliXML, shove it into a database, or just generate a report.
Hope this helps give you a start.