PS Script to Get License Count

$LicenseServer1=’CLSRV01′
$LicenseServer2=’CLSRV02′
$LicenseServer3=’CLSRV03′

# Get Citrix Licensing Info from WMI
$LicensePool1 = Get-WmiObject -ComputerName $LicenseServer1 -Namespace “ROOT\CitrixLicensing” -class “Citrix_GT_License_Pool” -filter “pld=’XDT_PLT_UD'”
$LicensePool2 = Get-WmiObject -ComputerName $LicenseServer2 -Namespace “ROOT\CitrixLicensing” -class “Citrix_GT_License_Pool” -filter “pld=’MPS_PLT_CCU'”
$LicensePool3 = Get-WmiObject -ComputerName $LicenseServer3 -Namespace “ROOT\CitrixLicensing” -class “Citrix_GT_License_Pool” -filter “pld=’MPS_PLT_CCU'”

# Calculate licenses in use, total number of licenses and percentage currently in use
$InUseNum1 = ($LicensePool1 | Measure-Object -Property InUseCount -sum).Sum
$InstalledLicNum1 = ($LicensePool1 | Measure-Object -Property Count -sum).Sum
$PercentageNum1 = [math]::round(($InUseNum/$InstalledLicNum1)*100,2)

$InUseNum2 = ($LicensePool2 | Measure-Object -Property InUseCount -sum).Sum
$InstalledLicNum2 = ($LicensePool2 | Measure-Object -Property Count -sum).Sum
$PercentageNum2 = [math]::round(($InUseNum/$InstalledLicNum2)*100,2)

$InUseNum3 = ($LicensePool3 | Measure-Object -Property InUseCount -sum).Sum
$InstalledLicNum3 = ($LicensePool3 | Measure-Object -Property Count -sum).Sum
$PercentageNum = [math]::round(($InUseNum/$InstalledLicNum3)*100,2)

# Check the usage and send an email if the license usage is over 1% so we get the number of users accessing Citrix
if ($PercentageNum1 -lt 1)
{
}
else
{
Send-MailMessage -To “murugan@myxenapp.com” -Subject “Citrix License Server Status $LicenseServer1” -Body “The Citrix license server is $LicenseServer1 `n`nTotal Available Citrix Licences: $InstalledLicNum1`nCurrent Licences In Use: $InUseNum1`nPercentage Of Licenses In Use: $PercentageNum1%” -SmtpServer “SMTP.myxenapp.com” -From “admin@myxenapp.com”
}

if ($PercentageNum2 -lt 1)
{
}
else
{
Send-MailMessage -To “murugan@myxenapp.com” -Subject “Citrix License Server Status $LicenseServer2” -Body “The Citrix license server is $LicenseServer2 `n`nTotal Available Citrix Licences: $InstalledLicNu2`nCurrent Licences In Use: $InUseNum2`nPercentage Of Licenses In Use: $PercentageNum2%” -SmtpServer “SMTP.myxenapp.com” -From “admin@myxenapp.com”
}

if ($PercentageNum3 -lt 1)
{
}
else
{
Send-MailMessage -To “murugan@myxenapp.com” -Subject “Citrix License Server Status $LicenseServer3” -Body “The Citrix license server is $LicenseServer3 `n`nTotal Available Citrix Licences: $InstalledLicNum3`nCurrent Licences In Use: $InUseNum3`nPercentage Of Licenses In Use: $PercentageNum3%” -SmtpServer “SMTP.myxenapp.com” -From “admin@myxenapp.com”
}

Advertisements

About Murugan B Iyyappan

Working as a Technical Specialist - Citrix solutions architect with 13 years of experience in the IT industry. Expertise in Citrix XenApp and VMware in Windows platform.
This entry was posted in Citrix XenApp. Bookmark the permalink.