Generating Per Device license usage reports for TS License Servers running Windows Server 2008

Generating Per Device license usage reports for TS License Servers running Windows Server 2008

  • Comments 4

In an earlier post, we showed how to create a per user license usage report in Windows Server 2008. Below we show how to create a per device license usage report.

On Windows Server 2003, a Per Device Terminal Services Client Access License (TS CAL) usage report could be generated using the Lsreport tool. In Windows Server 2008, the Lsreport tool is not supported. Instead, use the TS Licensing WMI interface to generate a Per Device TS CAL usage report in Windows Server 2008.

To generate a Per Device TS CAL usage report, you need to enumerate the Win32_TSIssuedLicense class instances on the license server. The following is a simple script that displays a list of issued Per Device TS CAL from a given license server with details like expiration date, etc.

'----------------------------------------------------------------------------

' Script to generate TS Per-Device license usage report.

' Requires Administrator privilege on the license server.

' Works only with WS08 TS License Server, as there is no WMI

' interface for TS Licensing on earlier versions.

'----------------------------------------------------------------------------

SET Args = WScript.Arguments

NameSpace = "root\cimv2"

ClassName = "Win32_TSIssuedLicense"

IF Args.Length > 2 THEN

Help

WSCRIPT.QUIT(1)

END IF

IF Args.Length = 1 THEN

Help

WSCRIPT.QUIT(1)

END IF

IF Args.Length = 2 THEN

' Checking if Server Name has been provided

CompResult = strComp(Args(0), "-server",1)

IF CompResult = 0 THEN

ServerName = Args(1)

ELSE

Help

WSCRIPT.QUIT(1)

END IF

ELSE

' if argc.length = 0, no arg supplied

ServerName = "."

END IF

GeneratePerDeviceReport

WSCRIPT.QUIT

'----------------------------------------------------------------------------

' FUNCTIONS

'----------------------------------------------------------------------------

SUB Help()

WSCRIPT.ECHO "Usage: GeneratePerDeviceReport.vbs [-Server ServerName]"

WSCRIPT.ECHO " If no ServerName is provided, then report generation"

WSCRIPT.ECHO " is attempted at host machine"

END SUB

SUB GeneratePerDeviceReport()

Err.Clear

Set ObjWMIService = GetObject("winmgmts:\\" & ServerName & "\" & NameSpace )

IF ERR.NUMBER <> 0 THEN

WSCRIPT.ECHO "Unable to connect to the Namespace"

WSCRIPT.QUIT(2)

END IF

Set ObjectSet = ObjWMIService.ExecQuery ("Select * from Win32_TSIssuedLicense")

ReportCountBefore = ObjectSet.Count

' No Reports are present

IF ObjectSet.Count = 0 THEN

WSCRIPT.ECHO "No Per Device license issued"

WScript.Quit(5)

END IF

WSCRIPT.ECHO "KeyPackID,LicenseID,IssuedToMachine,HWID,ExpiryDate"

FOR EACH ObjectClass IN ObjectSet

WSCRIPT.ECHO ObjectClass.KeyPackId & "," & ObjectClass.LicenseId & "," & ObjectClass.sIssuedToComputer & "," & ObjectClass.sHardwareId & "," & ObjectClass.ExpirationDate

NEXT

END SUB

Per device license usage reports for all the discoverable license servers can be generated by getting the list of license servers using WMI method Win32_TerminalServiceSetting::FindLicenseServers () and running the above script for each license server.

Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post
  • PingBack from http://blogs.msterminalservices.org/conger/2007/08/10/generating-per-device-license-usage-reports-for-ts-license-servers-running-windows-server-2008/

  • I have tried to use the script but It gives an error:  Access Denied 80041003 . Source: Swbem oject set

    The problem is in this line: ReportCountBefore = ObjectSet.Count

    I have launched the .vbs file with Local Administrator account in the License Server (locally )

    Have I forgotten something to change/add in the script ?

  • Hello There.

    Im getting slightly off Values compared to the Console? can someone Explain ?

    for Example i have 3 Pools of Licenses. the Script says Issued 1495, 1002 and 29 .

    The RD Licensing Manager says 1489 992 and 29 Issued. is there a Reason / explanation for this (Expecially the Second value Baffles me since the Pool is only 1000 Licenses big).

  • @Ceuse,

    These differences could be a result of slightly different ways in which license usage data is retrieved for display in the RD Licensing Manager vs. in this script. RD Licensing Manager information does not include expired or revoked licenses while this script does, which is why you see slightly larger numbers using this script.

    You can add the LicenseStatus field to this script so that this information is displayed in the report, and use the status information to understand the report more clearly. License status has six possible values: Unknown=0, Temporary=1, Active=2, Upgrade=3, Revoke=4, Pending=5, Concurrent=6. More information here:

    msdn.microsoft.com/.../aa383802%28v=vs.85%29.aspx

    If you are running Windows Server 2012 or higher, I'd recommend using the GenerateReportEx method in the Win32_TSLicenseReport class.

    msdn.microsoft.com/.../hh769106(v=vs.85).aspx

Page 1 of 1 (4 items)