Calculate vSphere 5 Licenses with Powershell (UPDATED)

VMware has announced the next generation of vSphere yesterday. Besides lots of new features, vSphere 5 also comes with a new licensing structure. For every licensed physical CPU, you get a certain amount of vRAM, which you will be able to allocate to virtual machine. Only the running VM’s will count towards your license limit.
Curious how the vSphere 5 licensing model will impact your license cost? Want to know how many vSphere 5 liceses you will need? The following script calculates exactly how many licenses you need for the different editions and how much overhead you will have left.

UPDATE 04-AUG-2011: vmware has increased vRAM entitlements for all editions of vSphere 5! I have updated the script (shown below and the attached script). The screenshot is still the old one. Please read the new Licensing PDF here for all the details.

NOTE: Please note that I add up all your pCpu’s, ignoring current license types. I also add up all your current vRAM usage (RAM assigned to powered on VM’s). I then show you different scenarios if you purchase license type x for ALL your pCpu’s. If your environment consists of a mix of vSphere editions, check out Alan Renouf’s script to analyse your environment.

$vCenterServerName = "MyVC1.domain.local", "myVC2.domain.local" # Enter your vCenter server name here. In case of multiple vCenter servers, separate using a comma.
$ErrorActionPreference = "Stop"
# Connect to vCenter(s)
Write-Host "Connecting..."
$VC = Connect-VIServer $vCenterServerName
Write-Host "Counting physical cpu's and vRAM in your environment. Please be patient..."
# Gather information
$pCpu = (Get-VMHost | Get-View | Select -ExpandProperty Hardware | Select -ExpandProperty CpuInfo | Measure-Object -Property NumCpuPackages -Sum).Sum
$vRAM = [Math]::Round((Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Measure-Object -Property MemoryMB -Sum).Sum/1024,0)
Write-Host "======"
"pCpu Count: {0}" -f $pCpu
"vRAM (GB):  {0}" -f $vRAM
Write-Host "======"
# Disconnect
Disconnect-VIServer $vCenterServerName -Confirm:$false
# Calculate required licenses
$licCol = @()
$licObj = "" | Select Edition, Entitlement, Licenses
$licObj.Edition = "Essentials/Essentials Plus/Standard"
$licObj.Entitlement = "1 pCpu + 32 GB vRAM"
If (($vRAM/32) -gt $pCpu)
	$licObj.Licenses = "{0} with {1} pCpu overhead" -f [Math]::Ceiling($vRAM/32), ([Math]::Ceiling($vRAM/32) - $pCpu)
	$licObj.Licenses = "{0} with {1} GB vRAM overhead" -f $pCpu, ((32 * $pCpu) - $vRAM)
$licCol += $licObj
$licObj = "" | Select Edition, Entitlement, Licenses
$licObj.Edition = "Enterprise"
$licObj.Entitlement = "1 pCpu + 64 GB vRAM"
If (($vRAM/64) -gt $pCpu)
	$licObj.Licenses = "{0} with {1} pCpu overhead" -f [Math]::Ceiling($vRAM/64), ([Math]::Ceiling($vRAM/64) - $pCpu)
	$licObj.Licenses = "{0} with {1} GB vRAM overhead" -f $pCpu, ((64 * $pCpu) - $vRAM)
$licCol += $licObj
$licObj = "" | Select Edition, Entitlement, Licenses
$licObj.Edition = "Enterprise Plus"
$licObj.Entitlement = "1 pCpu + 96 GB vRAM"
If (($vRAM/96) -gt $pCpu)
	$licObj.Licenses = "{0} with {1} pCpu overhead" -f [Math]::Ceiling($vRAM/96), ([Math]::Ceiling($vRAM/96) - $pCpu)
	$licObj.Licenses = "{0} with {1} GB vRAM overhead" -f $pCpu, ((96 * $pCpu) - $vRAM)
$licCol += $licObj
# Displaying output
Write-Host "Resulting license options:"
Write-Host "======"
Write-Host "NOTE: vRAM only counts memory allocated to vm's that are POWERED ON." -ForegroundColor Red 
Write-Host "NOTE: Please double check the results of this script, since hosts may have been omitted due to errors." -ForegroundColor Red 
Write-Host "Disclaimer: No rights can be deduced from this calculation." -ForegroundColor Red
Write-Host "======"

You can download the script here (rename to .ps1): Get-vSphere5LicensesUpdated

Don’t forget to use PowerCLI to run the script, or add the PowerCLI snapin to your Powershell session (Add-PSSnapIn vmware*).


56 thoughts on “Calculate vSphere 5 Licenses with Powershell (UPDATED)

  1. Thx for the script, but unfortunately i got the below error while running it.

    Counting physical cpu’s and vRAM in your environment. Please be patient…
    Select-Object : Cannot process argument because the value of argument “obj” is
    null. Change the value of argument “obj” to a non-null value.
    At E:\lic.ps1:11 char:40
    + $pCpu = (Get-VMHost | Get-View | Select <<<< -ExpandProperty Hardware | Sele
    ct -ExpandProperty CpuInfo | Measure-Object -Property NumCpuPackages -Sum).Sum
    + CategoryInfo : InvalidArgument: (:) [Select-Object], PSArgument
    + FullyQualifiedErrorId : ArgumentNull,Microsoft.PowerShell.Commands.Selec

    • Hey Sanjai,
      It appears the script cannot read the number of pCpus for one of your hosts. Make sure you have permissions and all hosts are available. You can change $ErrorActionPreference to “Continue”, but remember the results may be incomplete due to the error on one or more hosts!

  2. This script does not seem to calculate the individual pools by Edition. Read the FAQ carefully, there are 5 separate vRAM pools, one for each edition.

  3. Very nice script!
    I still am trying to wrap my head around the results.
    So what does it mean for the following…
    “130 with 42 pCpu overhead”
    Does this mean that I will need 42 more licenses or that I would have 42 pCpu of “cushion”?

  4. You will need 130 licenses in order to have enough vRAM in your pool. But you have 42 less pCpu’s than that (and likely 42 less licenses now).

  5. […] Peeters Online just posted a powershell script to figure out how many licenses you need: This entry was posted in Cloud. Bookmark the permalink. ← vSphere 5 Officially […]

  6. Bilal,

    I was having the same error. I modified the script to just run against one cluster of my choosing. I found the error was caused by a cluster that had a “disconnected” host. Once I removed the host I was able to run the original script.

    Good luck.

  7. […] you can use to calculate your vRAM configurations/vSphere 5 licensing needs:  Script 1, and Script 2. This entry was posted in VMware and tagged licensing, vmware, vSphere. Bookmark the permalink. […]

  8. […] 14:26: Tweaker hpeeters heeft een PowerShell-script ontwikkeld waarmee vSphere-klanten kunnen uitrekenen of en hoe zij de gevolgen van de nieuwe licentiestructuur voelen in hun […]

  9. Thx for the script.

    This is my result…

    BUSINESS CASE 1 (1x VM with 1TB RAM):
    If you want to run 1 VM with 1TB RAM you will need to buy 21 vSphere5 Enterprise Plus licenties.

    This VM you can run it on 1x vSphere DL580 4CPU 8Cores 1TB RAM -> 4CPUs = 4 Enterprise Plus licenses
    with vRAM entitlements: 1TB : 48GB per licentie = 21 licenses Price: 21 * €3.078 = €64.638

    from 4 -> 21 = increase of 525% !!

    BUSINESS CASE 2 (my current ESX4.1 clusters):

    1 cluster = 8x DL580G7 4CPU 8Cores 512GB
    Ratio 20:1 -> 80VMs / host * (8hosts per cluster – 1 for HA) = 560 VMs per cluster

    Mix 560 VMs = (280 VM * 4GB) + (140 VM * 8GB) + (70 VM * 16GB) + (70 VM * 32GB) = 5.600 GB configured per cluster (= avg 10GB / VM)

    vSphere 4.1 licensing : 8 hosts * 4 CPU = 32 Enterprise Plus licenses
    vSphere 5.0 licensing : 5.600 GB : 48GB = 117 Enterprise Plus licenses
    from 32 -> 117 = increase of 365% !!

    Thx to VMware

  10. […] Netherlands blog has written an excellent script to run against your vCenter to calculate your new vSphere 5 vRAM License details. So far, I have not seen a single environment across my customers who don’t already have far […]

  11. I would love to be able to add to this to also count the vRAM that’s actually in use (active/granted) but I can’t find anything in the Cmdlets reference that would work. Maybe you’ve got an idea of what I should look for?

    • Add the following parameter both to get-vmhost and get-vm:
      -location (get-cluster )
      I hope that’s clear enough, typing on my iPhone here.

  12. This is great work. I work at VMware and I encourage my customers to run your script so they have an idea of what’s coming.

    I have a question however. One of my customers ran both your script and virtu-al’s and the results are completely different. There doesn’t seem to be any errors during runtime. One virtu-al’ comes back with 84 pCPU, around 1300 GB vRAM; you script comes back with 83 pCPUs, around 2600 GB vRAM.

    Do you know where such a difference could come from? I looked around and didn’t find any post on this issue.

  13. Please note that I add up all your pCpu’s, ignoring current license types. I also add up all your current vRAM usage (RAM assigned to powered on VM’s). I then show you different scenarios if you purchase license type x for ALL your pCpu’s.
    What Alan does is different. He looks at your current licenses and counts pCpu’s per license type. He also sums up vRAM usage per license type and then shows what happens when you change your vSphere4 licenses to vSphere 5 licenses, keeping the same number of each license type.


  14. Thanks Hugo. Greatly appreciated. I’ll pass the information to my customer.

    Either way he is well overprovisioned on the vRAM side.

    Great job Hugo.

  15. How would one modify this to hit only a cluster? I’ve run this script successfully, but the connection goes to my management server and hits up all hosts that vSphere manages. We are migrating everything to our blade clusters and our Dell PowerEdge cluster is going bye-bye.

  16. […] to one version, a second,  and  another.  The third is “official VMware” since it is […]

  17. Thanks for the script and I got it to run but I’m not getting the right total pCPU’s. From your script, I get 44 pCPUs but when I looked at Virtual Center and count manually “CPU Count”, I only have 22. I tried it on other VCs that we have and seems to double up. Any reason why it doubles up on your script? I don’t know which is the correct info.

  18. BM,

    Odd. You can do a quick check by looking at your license overview in the vSphere client. The cpu count you have there should be equal to the physical cpu’s you need to license.
    Please note that vRAM entitlements have been increased by vmware today and the script has been updated.


  19. Figured it out, I was using an older vitoolkit. I updated it to the latest version and it picked up the right CPU information.

  20. Hello exceptional website! Does running a blog such as this require a lot of work? I’ve no understanding of programming but I had been hoping to start my own blog in the near future. Anyhow, if you have any ideas or tips for new blog owners please share. I understand this is off topic however I simply wanted to ask. Many thanks!

  21. Thank you for the script. I have 1 quick question, in your script where you are calculating the vRAM amount, you are taking the Sum/1032. How did you come up with the number 1032, I guest I would expected to see the number 1024.

    Thank you.

  22. Good script… is there a way to have it populate the individual hosts and the # of phsyical CPU?

    For instance… add what hosts have what number of CPU and edition??

    Edition Entitlement Licenses
    ——- ———– ——–
    Essentials/Essentials P… 1 pCpu + 32 GB vRAM 12 with 344 GB vRAM ov…
    Enterprise 1 pCpu + 64 GB vRAM 12 with 728 GB vRAM ov…
    Enterprise Plus 1 pCpu + 96 GB vRAM 12 with 1112 GB vRAM o…

Leave a Reply