How can I say this relevance is less than "01 May 2026"?
(if exists integer value of it and integer value of it >0 then now + (minute * (integer value of it)) else nothing) of ((selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null" of wmi)) as string as time
Consider this example:
Q: (now + minute * ("124639" as integer)) as local date
A: Thu, 05 Feb 2026
Q: (now + minute * ("124639" as integer)) as local date < "01 May 2026" as date
A: True
Perhaps:
((if exists integer value of it and integer value of it > 0 then now + (minute * (integer value of it)) else nothing) of ((selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null" of wmi)) as string as time) as local date < "01 May 2026" as date
I don't have the wmi entry to test against, so I substituted an appropriate string for the example.
I dont have any device with actual data but my device does return a plural WMI object so that may throw some complication if you have devices with multiple non-zero values.
Q: (selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null" of wmi)
A: GracePeriodRemaining=0
A: GracePeriodRemaining=0
A: GracePeriodRemaining=0
A: GracePeriodRemaining=0
A: GracePeriodRemaining=0
T: 1106.607 ms
I: plural wmi select
Q: (if exists integer value of it and integer value of it > 0 then now + (minute * (integer value of it)) else nothing) of ((selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null" of wmi))
T: 751.799 ms
I: plural time
If you try to cast that to a date, you’ll possibly run into issues
Q: (if exists integer value of it and integer value of it > 0 then now + (minute * (integer value of it)) else nothing) of ((selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null" of wmi)) as string as time as local date < "01 May 2026" as date
E: A singular expression is required.
This may work around that scenario
Q: disjunction of ((it < "01 May 2026" as date) of (((if ((exists integer value of it) and (integer value of it > 0)) then (now + (minute * (integer value of it))) else (nothing)) of (selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null" of wmi)) as local date))
A: False
T: 397.857 ms
I: singular boolean
I like this SLB! Nice handling of the plural.
Here is another way that does not use the disjunction
exists (integer values of selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null" of wmi) whose (it > 0 and (it*minute + current date) <"01 May 2026" as date )
Thank you!
I did have to add an additional qualifier because I was picking up Office, as well as, Windows license grace period. I queried for the PartialProductKey = ‘XXXX’. Where ‘XXXX’ is our partial product key.
disjunction of ((it < "01 May 2026" as date) of (((if ((exists integer value of it) and (integer value of it > 0)) then (now + (minute * (integer value of it))) else (nothing)) of (selects "GracePeriodRemaining from SoftwareLicensingProduct WHERE PartialProductKey is not null and PartialProductKey = 'XXXX'" " of wmi)) as local date))
We took another approach for calculating less or more than a date, for ESU content.
We have the content but if one of our customers wants us to patch them with the content, we charge them. So I had to come up with a way to allow paying customers access to the content (ESU Baselines in my case) and not allow others.
Other than just setting a client setting with TRUE, you have access, we also wanted to ensure they did not get Year2 without paying, because we forgot to remove their access.
So here is what we did. We store the license expirydate in this format: 20250125. Doing so will allow you to determine if one date is less than or greater than another.
Today less than October 13, 2026
q: 20251113 < 20261013
A: True
T: 0.696 ms
is two days after October 13, 2026 less than October 13, 2026
q: 20261015 < 20261013
A: False
T: 0.414 ms
We have a task that will set the expirydate and it has some error checking. It also has a required ticket number question because the tickets have the proof of purchase of the content.
// Query for Expirey date
action parameter query "SetExpire" with description "Please enter the Expiry date, in format YYYYMMDD (Ex. 20250125) :" With default ""
//Get the ticket number
action parameter query "SetTicket" with description "Please enter JUST the Ticket Number:" With default ""
//Verify the data entered is valid, 8 digist long (YYYYMMDD) and starts with the year 202?
continue if { exists (parameter "SetExpire" of action) whose (length of it as integer = 8) }
continue if { substring (0,3) of (parameter "SetExpire" of action) = "202" }
continue if { parameter "SetExpire" of action as integer > (year of it as string & month of it as two digits & day_of_month of it as two digits) of current date as integer}
//Now set up all settings
//Date the auth will expire
regset64 "[HKEY_LOCAL_MACHINE\SOFTWARE\MYCO\MYCOWIN1022H2EXT]" "expirydate"="{parameter "SetExpire" of action}"
//Setting to allow access to the baseline
setting "MYCO_MYCOWIN1022H2EXT"="True" on "{parameter "action issue date" of action}" for client
//Set a ticket number property that will be picked up by our reporting tool.
setting "MYCO - Tickets"="{parameter "SetTicket" of action} (Enable ESU Patching)" on "{parameter "action issue date" of action}" for client
(Sorry, it keeps losing the formatting when I paste it, I think because of the line length, so I put a new line between each command)
We stored this expiry date in the registry, but it could also be stored in a client setting.
Then the relevance in our baseline will only allow systems that have the MYCO_MYCOWIN1022H2EXT property as True and the date is less than October 13, 2026 (ESU year one expires)
(value whose (name of it is "expirydate") of key "HKEY_LOCAL_MACHINE\SOFTWARE\MYCO\MYCOWIN1022H2EXT" of x64 registries as integer) > ((year of it as string & month of it as two digits & day_of_month of it as two digits) of current date as integer)