Windows License Status
Summary
This monitor will identify computers where the license key is reported as inactivated or in a grace period.
Monitor
-
Go to
Alert Management
>Monitors
>Add monitor
-
Click the
Create Monitor
button.
-
This screen will appear.
-
Name: Windows License Status
Description: The monitor will detect computers with expired Windows license keys.
Type: Script
Family: Critical Impact Alerts
Severity: Desktop Operating System
-
The
Conditions
tab will start looking like this:
-
Set the
Repeat every
to 24 Hours:
-
Disable the
Ticket Resolution
section by clicking theAutomatically resolve
button.
-
The
Conditions
section will change to this:
-
Paste this PowerShell script in the
Script
box.$ErrorActionPreference = 'SilentlyContinue';
(Get-CimInstance -Class SoftwareLicensingProduct -Filter "Name LIKE 'Windows%'" |
Where-Object { $_.PartialProductKey } |
Select-Object @{
label = 'LStatus';
expression = {
switch ($_.LicenseStatus) {
0 { 'Unlicensed' }
1 { 'Licensed' }
2 { 'OOBGrace' }
3 { 'OOTGrace' }
4 { 'NonGenuineGrace' }
5 { 'Notification' }
6 { 'ExtendedGrace' }
}
}
}).LStatus -
Change the comparator to
OR
fromAND
-
Set
Unlicensed
andNonGenuineGrace
to theScript Output
box.
-
Enable the
Escalate ticket on script failure
.
-
Select the required client to target from the
Select Targets
button.
-
Final look:
-
Click the
Save
button to save the monitor set.