VMware Cloud Community
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Find the processor type for all hosts for VMs located in a certain folder its' subfolders

Hello,

We have both Intel and AMD hosts. We have an application which runs across multiple clusters, some on AMD and some on Intel. I would like to provide a list of all the VMs and what type of processor the host that they run on is using. I found this which will give me a list of all the VMs in the folder and it's subfolders:

$folderName = 'MyApplication'
$folder = Get-View -ViewType Folder -Property Name -Filter @{'Name'=$folderName} | Select -ExpandProperty MoRefGet-View -
ViewType VirtualMachine -SearchRoot $folder |
Select Name

This gives the Name of the VMs, but how can I get the processor type of the host that the VM runs on ?

Thanks.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Just add a calculated property on the Select-Object

Get-View -ViewType VirtualMachine -SearchRoot $folder |
Select Name,@{N='VMHostCPU';E={(Get-View -Id $_.Runtime.Host).Hardware.CpuPkg[0].Description}}

If you need more details on the CPU, check what is available in the HostCpuPackage object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Just add a calculated property on the Select-Object

Get-View -ViewType VirtualMachine -SearchRoot $folder |
Select Name,@{N='VMHostCPU';E={(Get-View -Id $_.Runtime.Host).Hardware.CpuPkg[0].Description}}

If you need more details on the CPU, check what is available in the HostCpuPackage object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Wow you make it look so easy, I have a lot to learn about views and calculated properties!  It's exactly what I need, but how can I add the folder name and the cluster name to the output?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Again with calculated properties.
The trick is to know/learn which object points to which other objects.

The schematic on the ServiceInstance page will get you started.

Get-View -ViewType VirtualMachine -SearchRoot $folder |
Select Name,
  @{N='CPUFamily';E={(Get-View -Id $_.Runtime.Host).Hardware.CpuPkg[0].Description}},
  @{N='Folder';E={(Get-View -Id $_.Parent).Name}},
  @{N='Cluster';E={(Get-View -Id (Get-View -Id $_.Runtime.Host).Parent).Name}}

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

dbutch1976
Hot Shot
Hot Shot
Jump to solution

Thanks LucD!

0 Kudos