Quantcast
Channel: admin – PEETERSONLINE.NL
Viewing all articles
Browse latest Browse all 20

Calculate vSphere 5 Licenses with Powershell (UPDATED)

$
0
0

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!


Viewing all articles
Browse latest Browse all 20

Trending Articles