Citrix Udadmin Delete Script & Event 1163

Scenario:

Users are unable to logon to their Citrix XenDesktop 5 desktops, and the following error is seen in the Windows Application log on the XenDesktop 5 Controller:
Event 1163, Citrix Broker Service : No connection license available. To resolve, free licenses by closing sessions that are not needed, or add more licenses.”

Solution to free one license at a time:

i: Logon to the Citrix Licensing server and open up a command prompt.
ii: Run the command below to 'list all licensed users and devices organized by feature and version':

udadmin -list -a

iii: Then run either the first command below to 'delete a licensed user from the feature specified' or the second command below to 'delete a licensed device from the feature specified' (Note that … -device … -delete did not work until Citrix License Server Version 11.9 Build #11011.)

udadmin -f featurename -user username -delete
udadmin -f featurename -device devicename -delete

Solution to free multiple licenses at a time:

i: From a command prompt run the command

udadmin -list -a > users.txt

ii: Edit the users.txt file to contain just the user strings (users or devices) as desired (don't worry about preceding spaces,) remembering to note the feature name from the output.
iii: (If required) Edit strFeature string in udadmindelete.vbs script if different from XDT_ENT_UD.
iv: (If required) Change strUserDev string in udadmindelete.vbs script from user to device if running against a list of devices.
v: Double-click on the udadmindelete.vbs script to run (the users.txt file needs to be in the same location as the udadmindelete.vbs script.)

And we're done!

udadmindelete.vbs script:

Copy all the contents below into a text document and save as udadmindelete.vbs.
Remember to change the string contents for strFeature and strUserDev (user or device) as per requirements.
Apologies if this is not the most elegant script, was a mash up of bits and pieces from around the net!

Option Explicit
Dim objFSO, strTextFile, strData, strLine, arrLines, objShell, strTmp, strFeature, strUserDev
CONST ForReading = 1
set objShell = wscript.createObject("wscript.shell")

'Name of the text file to be read
strTextFile = "users.txt"

'ADJUST strFeature AS PER REQUIREMENTS
strFeature = "XDT_ENT_UD"

'ADJUST strUserDev AS PER REQUIREMENTS
strUserDev = "user"

'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Open the text file - strData now contains the whole file
strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAll

'Split the text file into lines
arrLines = Split(strData,vbCrLf)

'Step through the lines
For Each strLine in arrLines
strTmp = "udadmin -f " & strFeature & " -" & strUserDev & " " & strLine & " -delete"
'To see the command being, run add a line below with wscript.echo strtmp
objShell.Run strTmp
Next

'Cleanup
Set objFSO = Nothing

Comments

  1. Change line:
    strTmp = "udadmin -f " & strFeature & " -" & strUserDev & " " & strLine & " -delete"
    in:
    strTmp = "udadmin -f " & strFeature & " -" & strUserDev & " " & LTrim(strLine) & " -delete"
    to remove the preceding spaces.

    ReplyDelete
    Replies
    1. Hello Anonymous, thank you for the comment. Cheers!

      Delete
    2. Hi,

      what is to be done to no approve any line by clicking ok, but just let it run in a batch?

      Cheers,
      Oliver

      Delete
    3. Hi Anonymous,
      In practice I found the lines that aren't relevant just error and are skipped (not processed in any way.)
      Cheers!

      Delete
    4. Hi Vidad,

      when I take the lines given above in a vbs, I have to approve every license to be deleted.
      Is it possible to change that behaviour to run automatically through the text file?

      Cheers,
      Oliver

      Delete
    5. Hi Oliver,
      It should run without prompting for approval. Perhaps a Windows security setting is hindering the script from running through, and is it being run as an administrator.
      Cheers!

      Delete
    6. Hi Vidad,

      ok thanks for your reply.

      Oliver

      Delete

Post a Comment