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
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
' if argc.length = 0, no arg supplied
ServerName = "."
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)
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)
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
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.
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 ?