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.
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
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
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?
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
Thanks LucD!