Detecting ESU product
Posted: 02.11.2020, 23:33
To be able to create a warning, if an ESU license is required, I tried to create a script, which works similar to slmgr.vbs to query the ESU-licenses. The question is, which licensing status allow the installation of ESU-updates and which do not.
The idea I have would check the signing date of wsusscn2.cab and the licensing status ESU licenses, if it seems to be an invalid combo, it should show a warning or refuse to do the dynamic search.
"Unlicensed" -> most likely not
"Licensed" -> most likely
"OOBGrace" -> ???
"OOTGrace" -> ???
"NonGenuineGrace" -> ???
"Notification" -> most likely not
"Unknown" -> most likely not
Is there someone out there, who is able to test it?
To get the licensing status for an ID, just run
from an administrative command prompt and replace "<activation ID>" with the activation id from the next post.
I'll post the IDs required to query the licenses in the next post.
The script (WindowsLicensingDemoScript.vbs):
The idea I have would check the signing date of wsusscn2.cab and the licensing status ESU licenses, if it seems to be an invalid combo, it should show a warning or refuse to do the dynamic search.
"Unlicensed" -> most likely not
"Licensed" -> most likely
"OOBGrace" -> ???
"OOTGrace" -> ???
"NonGenuineGrace" -> ???
"Notification" -> most likely not
"Unknown" -> most likely not
Is there someone out there, who is able to test it?
To get the licensing status for an ID, just run
- Code: Select all
cscript WindowsLicensingDemoScript.vbs <activation ID>
from an administrative command prompt and replace "<activation ID>" with the activation id from the next post.
I'll post the IDs required to query the licenses in the next post.
The script (WindowsLicensingDemoScript.vbs):
- Code: Select all
Option Explicit
private const LicenseStatus_Unlicensed = 0
private const LicenseStatus_Licensed = 1
private const LicenseStatus_OOBGrace = 2
private const LicenseStatus_OOTGrace = 3
private const LicenseStatus_NonGenuineGrace = 4
private const LicenseStatus_Notification = 5
private const LicenseStatus_ExtendedGrace = 6
Dim objWMIService, objQueryItem, strQueryClause
strQueryClause = "Select ID, Name, PartialProductKey, LicenseStatus, LicenseStatusReason from SoftwareLicensingProduct"
If WScript.Arguments.Count >= 1 Then
strQueryClause = strQueryClause & " Where ID = '" & WScript.Arguments(0) & "'"
Else
strQueryClause = strQueryClause & " Where PartialProductKey <> null"
End If
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
' Documentation: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/sppwmi/softwarelicensingproduct
For Each objQueryItem in objWMIService.ExecQuery(strQueryClause)
WScript.Echo "ID: " & objQueryItem.ID
WScript.Echo "Name: " & objQueryItem.Name
'WScript.Echo "PartialProductKey: " & objQueryItem.PartialProductKey
WScript.Echo "LicenseStatus: " & objQueryItem.LicenseStatus
WScript.Echo "LicenseStatusReason: " & objQueryItem.LicenseStatusReason
If (objQueryItem.LicenseStatus = LicenseStatus_Unlicensed) Then ' Unlicensed
WScript.Echo " Unlicensed"
ElseIf (objQueryItem.LicenseStatus = LicenseStatus_Licensed) Then ' Licensed
WScript.Echo " Licensed"
ElseIf (objQueryItem.LicenseStatus = LicenseStatus_OOBGrace) Then ' OOBGrace
WScript.Echo " OOBGrace"
ElseIf (objQueryItem.LicenseStatus = LicenseStatus_OOTGrace) Then ' OOTGrace
WScript.Echo " OOTGrace"
ElseIf (objQueryItem.LicenseStatus = LicenseStatus_NonGenuineGrace) Then ' NonGenuineGrace
WScript.Echo " NonGenuineGrace"
ElseIf (objQueryItem.LicenseStatus = LicenseStatus_Notification) Then ' Notification
WScript.Echo " Notification"
ElseIf (objQueryItem.LicenseStatus = LicenseStatus_ExtendedGrace) Then ' ExtendedGrace
WScript.Echo " ExtendedGrace"
Else
WScript.Echo " Unknown"
End If
WScript.Echo ""
Next
WScript.Quit(0)