Microsoft Windows Experts

Retrieve Terminal Services Licensing Grace Period Days info via WMI January 25, 2011

Script to retrieve the number of days left in your TS Licensing Grace Period:
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\CIMV2\TerminalServices”)
‘ Obtain an instance of the the class
‘ using a key property value.
Set objShare = objWMIService.Get(“Win32_TerminalServiceSetting.ServerName=’WIN-7′”)

‘ no InParameters to define

‘ Execute the method and obtain the return status.
‘ The OutParameters object in objOutParams
‘ is created by the provider.
Set objOutParams = objWMIService.ExecMethod(“Win32_TerminalServiceSetting.ServerName=’WIN-7′”, “GetGracePeriodDays”)

‘ List OutParams
Wscript.Echo “Out Parameters: ”
Wscript.echo “DaysLeft: ” & objOutParams.DaysLeft
Wscript.echo “ReturnValue: ” & objOutParams.ReturnValue

Note: Win-7 is the name of the machine, you may change it to the machine in question.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s