Thursday, May 14, 2015

Citrix License Server / Concurrent License Check & Email

This is a script I have built to email me when the license server has issued some level of licenses determined by the variable $licensealertlevel (set at the top). I have this set as a scheduled task on the license server running a powershell script. There is no warranty or support with this code. Use at your own risk.

#############################################################
#Set license alert level
$licensealertlevel = 3500

#change path to the folder with the EXE
Set-Location -path "c:\Program Files (x86)\Citrix\Licensing\LS"

#bring in results for specific licenses you're using
$a = Invoke-Command -scriptblock { .\lmstat.exe -c "..\MyFiles\<License file>" -a | find "Users of LICENSEMODE" }
#where LICENSEMODE is the license mode you're checking for, e.g. XDT_ENT_CCS

#match numerical values
$b = ( $a | select-string "\d+" -AllMatches )

if ($b.matches[1].value -gt $licensealertlevel) {
#build body of email
$body = $b.matches[1].value + " of " + $b.matches[0].value + " licenses are currently used"

#use quick powershell to send email
send-mailmessage -to "email" -from "email" -subject "!!!ALERT!!! Licenses Used" -body $body -SmtpServer smtpserver
}
#############################################################

You may need to use some of the info at the following link to figure out what your license mode should be. http://support.citrix.com/proddocs/topic/licensing-1110/lic-admin-cmds-status-r.html

No comments:

Post a Comment