Hi Guys
I just have a quick question about gathering host information via powercli.
In my environment we have a good few hosts connected to the vCenter. 5.0 the majority of these hosts are built from the manufacturers custom iso and some have been built using a generic ISO.
Normally when I just want a quick inventory I will just use the command:
Get-VMHost | Select Name,Build,Version etc.
And if I want finer detail I will drill down with another commandlet.
But I want to check if a host was built from a custom ISO or from Generic one. I can see from the summary tab that the Image Profile has this property.
Is there a script I can use to pull this information? There is a caveat though. I was looking at Get-VMHostImageProfile I have not installed the VMware Autodeploy service on the VC as we did not have the intention of using it. Is it possible to pull this information from the host?
On the summary its here:
Thanks
John
If I do use the cmdlet Get-VMhost|Get-VMHostImageprofile I will get the error There is no vCenter AutoDeploy Extension registered with vCenter Server. As its a production enviroment its very difficult to install additional services.
Try this
$esx = Get-VMHost MyEsx
$imgMgr = Get-View $esx.ExtensionData.ConfigManager.ImageConfigManager
$imgMgr.HostImageConfigGetProfile() | select Name,Vendor
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD
That is the property I am looking for. Unfortunately I just learning to script. I am guessing its possible to write a ForEach loop but I am at a loss as to what to do.
Here is what I came up with myself.
It seems to work. The only odd thing is that Vendor is the name of the host.
$esx = Get-VMHost '*'
ForEach( $esx in $esx){
$imgMgr = Get-View $esx.ExtensionData.ConfigManager.ImageConfigManager
$imgMgr.HostImageConfigGetProfile() | select Vendor,Name| Export-csv c:\buildreport.csv -append -notypeinformation}
Try something like this
foreach($esx in Get-VMHost){
$imgMgr = Get-View $esx.ExtensionData.ConfigManager.ImageConfigManager
$imgMgr.HostImageConfigGetProfile() |
Select @{N="VMHost";E={$esx.Name}},Name,Vendor
}
You were nearly there, but you used the same variable ($esx) for the collection of all the hosts and as the indexing variable for the ForEach loop
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference