Skip to main content

Windows License Status

Summary

This monitor will identify computers where the license key is reported as inactivated or in a grace period.

Monitor

  1. Go to Alert Management > Monitors > Add monitor
    Step 1

  2. Click the Create Monitor button.
    Step 2

  3. This screen will appear.
    Step 3

  4. 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
    Step 4

  5. The Conditions tab will start looking like this:
    Step 5

  6. Set the Repeat every to 24 Hours:
    Step 6

  7. Disable the Ticket Resolution section by clicking the Automatically resolve button.
    Step 7

  8. The Conditions section will change to this:
    Step 8

  9. 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

    Step 9

  10. Change the comparator to OR from AND
    Step 10a
    Step 10b

  11. Set Unlicensed and NonGenuineGrace to the Script Output box.
    Step 11

  12. Enable the Escalate ticket on script failure.
    Step 12

  13. Select the required client to target from the Select Targets button.
    Step 13a
    Step 13b

  14. Final look:
    Step 14

  15. Click the Save button to save the monitor set.
    Step 15