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)
}
Else
{
	$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)
}
Else
{
	$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)
}
Else
{
	$licObj.Licenses = "{0} with {1} GB vRAM overhead" -f $pCpu, ((96 * $pCpu) - $vRAM)
}
$licCol += $licObj
# Displaying output
Write-Host "Resulting license options:"
$licCol
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*).

Enjoy!

»crosslinked«

Tagged with:
 

55 Responses to Calculate vSphere 5 Licenses with Powershell (UPDATED)

  1. [...] came across this cool powershell script this morning that will help you determine the licensing needs for upgrading to vSphere 5. The script determines the number of physical CPUs in your environment and your vRAM and comes [...]

  2. sanjai says:

    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
    NullException
    + FullyQualifiedErrorId : ArgumentNull,Microsoft.PowerShell.Commands.Selec
    tObjectCommand

    • admin says:

      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!
      Hugo

  3. Bilal says:

    I get the error saying cannot expand property hardware because it has nothing to expand.

  4. Bilal says:

    Thats odd, I have all kinds of permissions on this thing.. thanks I will try the other script..

  5. admin says:

    Bilal,
    What version of PowerCLI and vCenter are you using?

  6. Bilal says:

    VI toolkit wouldnt let me run this would it?

  7. Bilal says:

    Yeah.. I think I just relaized what I did in the excitment.. lol will let you know how it works out now that I have had my coffee..

  8. Mark says:

    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.

  9. Chris says:

    This looks very helpful, will have to give it a run today.

  10. Todd Wright says:

    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”?

  11. admin says:

    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).

  12. Bilal says:

    Tried it on PowerCLI 4.1 and it came back with the same error :(

  13. [...] have now tested the script that Hugo Peeters has made for checking what licensing needed with a vSphere platform when upgrading to [...]

  14. [...] Peeters Online just posted a powershell script to figure out how many licenses you need: http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/ This entry was posted in Cloud. Bookmark the permalink. ← vSphere 5 Officially [...]

  15. TMac says:

    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.

  16. vSphere 5 Licensing “Evolution” | A Sys Admin Blog says:

    [...] 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. [...]

  17. VMware introduceert vSphere 5 en nieuwe licentiestructuur | internetnieuws24 says:

    [...] 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 [...]

  18. [...] Calculate vSphere 5 Licenses with Powershell: http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/ [...]

  19. Shane Williford says:

    Is this script also solely for v4.1? Is there a way to create one for 4.0 U2?

    Thanks.

  20. Welcome to vSphere-land! » vSphere 5 Links says:

    [...] License Validator Script (Virtu-al) Query vRAM (LucD) Discover Memory Overallocations (LucD) Calculate vSphere 5 Licenses with Powershell [...]

  21. DanPan says:

    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

  22. Script to Calculate your vSphere 5 License Requirements | Something Virtual says:

    [...] Netherlands blog PeetersOnline.nl 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 [...]

  23. Josh C says:

    Super helpful, thank you very much!

  24. B Fuddled says:

    Try as I may, it just keeps opening the script in Notepad. I’m new to Powershell, so I have no idea what I’m doing wrong. Can anyone offer a hint?

  25. [...] done the maths for my environment (thanks to Hugo Peters for the PowerCLI script to check) and I’m one of the 90% that VMware claim will see no increase in costs. We’re using [...]

  26. Brad C says:

    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?

  27. Mike H says:

    How could I modify this script to get the results from just one cluster and not the whole vCenter server?

    • admin says:

      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.
      Hugo

  28. Mike H says:

    I got it to work. Thanks!

  29. DavidL says:

    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.

  30. admin says:

    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.

    Hugo

  31. DavidL says:

    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.

  32. Chris says:

    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.

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

  34. BM says:

    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.

  35. admin says:

    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.

    Hugo

  36. BM says:

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

  37. [...] nicht mit Papier und Bleistift rechnen möchte, kann mit Hilfe eines Powershellskripts von Hugo Peeters den Lizenzbedarf einer bestehenden Anlage prüfen. Dieses Skript wurde bereits auf [...]

  38. [...] This post was Twitted by glendacanfield [...]

  39. Christian B says:

    Great and usefull script! Thank you very much!

  40. 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!

  41. Jim says:

    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.

  42. Justin says:

    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…

  43. Arthur says:

    prefect script!! ran it and know now for sure to migrate to Hyperv… sadly..

Leave a Reply