How can I audit the number of virtual CPU sockets/cores of each VM?

red

This one proved trickier than I first thought. The total number of cores (sockets multiplied by cores per socket) is easy enough to get with get-vm – but it doesn’t tell you anything about the number of virtual sockets or virtual cores per socket assigned.

In case you don’t know what I’m talking about, shown here, when you edit the vCPUs of a VM:

vmcpu

 

I was told the need for this was application licensing related – which is abnormal – as most other licensing requirements are usually based on the physical sockets and cores of the host.  Still, it was an interesting challenge.

Run this up in PowerCLI, after you’ve already used Connect-VIserver to connect to your vCenter server.

 

The resulting CSV file should then look like this (I added column headings in Excel):

vmcpu2

red

5 Comments How can I audit the number of virtual CPU sockets/cores of each VM?

  1. Daksh

    Hi Kamal,

    I’m looking for similar kind of ps to get vCPU/cores output for a particular VM for upto last 1 year in vSphere 5.5 environment.

    Can you help get one? I tried few but cores output is none.

    Thank you,
    Digvijay

    Reply
    1. Kamal

      A little trickier – but not impossible.

      Before you perform get-VM, perform a get-VMHost to get all hosts, then loop through the VMs on a per host basis, like this:

      For the guest operating system, it depends on whether you want the actual OS, or what it’s configured as (on the VMware side of things).

      For the actual OS, you could use get-WMIObject to query the win32_operatingsystem class (assuming it’s Windows VMs your looking at).

      If you want to know what your host thinks the OS is, when you do get-VM there is a property called “Guest” that you can refer to.
      EG: $vm.guest will return something like “DC01:Microsoft Windows Server 2016 (64-bit)”.
      (DC01 is my server name in that example)

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *