VMware Cloud Community
MariusRoma
Expert
Expert

Getting information about number of vCPU, sockets, shares, ...

I need to get a list off all the VMs in a given vSphere infrastructure and to get, for each vm, the number of vCPUs, the number of sockets, the number of cores, the CPU share level and number.

I need to get each value as a variable because I need to format the output according to a standard format.

I was able to create a script to get part of the information I need by copying from various forums and blogs but I am sure I made some mistakes, as for each VM it takes about 60 seconds and it is unusable.

Is there any efficient, optimized sample I can start from?

Regards

marius

0 Kudos
1 Reply
LucD
Leadership
Leadership

Try like this

Get-VM |

Select Name,NumCPU,

   @{N='CPU Blocks';E={[math]::Ceiling($_.ExtensionData.Config.Hardware.NumCPU/$_.ExtensionData.Config.Hardware.NumCoresPerSocket)}},

   @{N='CPU Cores/Block';E={$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},

   @{N='CPU Share';E={$_.ExtensionData.Config.CpuAllocation.Shares.Level}},

   @{N='CPU SHare Value';E={$_.ExtensionData.Config.CpuAllocation.Shares.Shares}}


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

0 Kudos