Citrix License Usage Monitoring using PowerShell

The below PowerShell script could be used to deliver automated emails on the Citrix License usage for Citrix Admins.

Where do you run this script from?

Citrix License Server

How do you run this?

The script could be saved as a file with an extension of .ps1

Also ensure that you have a folder called report_do_not_delete created in the C: drive on the license server. Also, make the relevant changes in the script marked in Red. Run the script as a scheduled task at a specific time to receive the license usage reports in your mailbox or run it manually from a PowerShell window in Admin mode

#Region Settings
#Your License Server
$CitrixLicenseServer = “yourlicenseservername”

#Do you want to report on licenses with 0 users?
$ShowUnusedLicenses = $true

#Toggle an alert above this percentage of licenses used
$UsageAlertThreshold = 0

#EndRegion Settings

#Region CollectData
#retrieve license information from the license server
$LicenseData = Get-WmiObject -class “Citrix_GT_License_Pool” -namespace “ROOT\CitrixLicensing” -ComputerName $CitrixLicenseServer

$usageReport = @()
$LicenseData | select-object pld -unique | foreach {
$CurrentLicenseInfo = “” | Select-Object License, Count, Usage, pctUsed, Alert
$CurrentLicenseInfo.License = $_.pld
$CurrentLicenseInfo.Count = ($LicenseData | where-object {$_.PLD -eq $CurrentLicenseInfo.License } | measure-object -property Count -sum).sum
$CurrentLicenseInfo.Usage = ($LicenseData | where-object {$_.PLD -eq $CurrentLicenseInfo.License } | measure-object -property InUseCount -sum).sum
$CurrentLicenseInfo.pctUsed = [Math]::Round($CurrentLicenseInfo.Usage / $CurrentLicenseInfo.Count * 100,2)
$CurrentLicenseInfo.Alert = ($CurrentLicenseInfo.pctUsed -gt $UsageAlertThreshold)
if ($ShowUnusedLicenses -and $CurrentLicenseInfo.Usage -eq 0) {
$usageReport += $CurrentLicenseInfo
} elseif ($CurrentLicenseInfo.Usage -ne 0) {
$usageReport += $CurrentLicenseInfo
#EndRegion CollectData
$usageReport |Select-Object @{name=’Date-time’;Expression={Get-Date} },License,Count,Usage,PctUsed,Alert|ft -AutoSize|Out-File -Append C:\report_do_not_delete\$(get-date -uformat “%Y-%m-%d”).txt
#$usageReport | Format-Table -AutoSize | out-file “C:\reports\usagereport.txt”

Send-MailMessage -From “[email protected]” -To “[email protected]” -Subject “Citrix XenApp license usage – Daily Report” -Body “Citrix XenApp license usage – Daily Report” -SmtpServer “” -Attachments “C:\report_do_not_delete\$(get-date -uformat “%Y-%m-%d”).txt”

XenApp and XenDesktop user/device licensing – troubleshooting and resetting the license count


We had a call from a customer saying that the users were getting a message stating that they were out of licenses when connecting to their XenApp/XenDesktop sessions. The customer had purchased a fixed number of user/device XenDesktop Enterprise licenses and they had reach the limit when performing user testing. That scenario is quite common when testing is performed with many users accessing the farm from various devices.


Procedure 1:

Introducing a new Citrix license management utility named UDADMIN. The tool is command line based and could be located in C:\Program Files (x86)\Citrix\Licensing\LS\  and the tool could only be run from that location by navigating there using a command line.


This will give you a list of all licenses currently in use.  From here you can manually delete licenses using the same command with a –delete switch.  License usage data is updated every 15 minutes, however restarting the license service will force an update.  Don’t worry if you accidentally delete a valid license – it won’t disrupt a current session and the license will simply be reissued at the next connection. below is a snippet of the udadmin -list command


The below command could be issued to delete a user or device license




  • udadmin -list Displays all the users and devices.
  • udadmin -list -a Lists all features, versions, counts of licenses, and the users and devices for each feature.
  • udadmin -f XDT_ENT_UD -user u8.08 -delete Releases one user from one feature.
  • udadmin -f XDT_ENT_UD -device dn01.88 -delete Releases one device from one feature.

Complete syntax for the UDADMIN utility can be found here:

Procedure 2

The below method is officially unsupported so use at your own risk.

Step 1 is to stop the Citrix Licensing service

Navigate to the cache directory under C:\Program Files (x86)\Citrix\Licensing\LS\resource\cache  and delete all the files under that.


Those files are binary files and as such couldnt be opened in a text editor. Purging the contents of the directory will reset the license usage count to 0. I found this method much quicker to fix the issue as opposed to deleting the licenses checked out one after the other via the Citrix’s official method.