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 2

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 8 and 4 and type the answer here:
  • Post
Page 1 of 1 (2 items)