Friday, April 29, 2011

Vmware PowerCLI script for Licensing

Do you think using the Licensing tab for checking what features are licensed on each host kind of frustrating?

Welcome aboard!!!

I created a powerCLI script which will dump ESX 3.5 Licensing usage into a csv file, so you can import into Excel and play with it.

Here it’s:

$path = ".\ResultESX.txt"

$ESXHosts = Get-VMHost |Get-View

$ServiceInstance = Get-View ServiceInstance
$LicenseMan = Get-View $ServiceInstance.Content.LicenseManager
$Query = $LicenseMan.QueryLicenseUsage
foreach ($ESXHost in $ESXHosts)
$LicUse = $LicenseMan.QueryLicenseUsage($ESXHost.MoRef)
Write-Host -ForegroundColor Yellow $ESXHost.Name
Write-Host "License Server: $($LicUse.Source.LicenseServer)"
$resultWrite = $ESXHost.Name + ";" + "License Server: $($LicUse.Source.LicenseServer);"
foreach ($Reservation in ($LicUse.ReservationInfo |Sort Key))
If ($Reservation.State-eq "licensed")
switch ($Reservation.key)
"esxFull" {$FriendlyName = "ESX Server Standard"; break}
"esxExpress" {$FriendlyName = "ESX Server Foundation"; break}
"backup" {$FriendlyName = "VMware Consolidated Backup Usage"; break}
"vmotion" {$FriendlyName = "VMotion"; break}
"drs" {$FriendlyName = "VMware DRS"; break}
"das" {$FriendlyName = "VMware HA"; break}
"esxHost" {$FriendlyName = "VirtualCenter Agent for ESX Server"; break}
"nas" {$FriendlyName = "NAS Usage"; break}
"iscsi" {$FriendlyName = "ISCSI Usage"; break}
"san" {$FriendlyName = "SAN Usage"; break}
"vsmp" {$FriendlyName = "Up to 4-way SMP"; break}
default {$Friendlyname = "Feature not yet in script";break}
$resultWrite = $resultWrite + ";$FriendlyName licensed for $($Reservation.Required) Processors"
Add-Content $path $resultWrite

If you have no idea how to start, take a look at PowerCLI Basics

No comments:

Post a Comment

Who am I

My photo
I’m and IT specialist with over 15 years of experience, working from IT infraestructure to management products, troubleshooting and project management skills from medium to large environments. Nowadays I'm working for VMware as a Senior Consultant, helping customers to embrace the Cloud Era and make them succefully on this journay. Despite the fact I'm a VMware employee these postings reflect my own opnion and do not represents VMware's position, strategies or opinios.

Most Viewed Posts

Blog Archive