Reads the licensing state of the Windows product, translating the numeric status into plain words — licensed, notification, grace period, non-genuine — and reporting the key channel, the partial product key and any remaining grace window. The check that catches the KMS host nobody has renewed.
powershell
# Windows License Activation Status
# Single use case: report activation state of the OS license
#-----------------------------------------------------------------
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
# LicenseStatus: 0=Unlicensed 1=Licensed 2=OOBGrace 3=OOTGrace 4=NonGenuineGrace 5=Notification 6=ExtendedGrace
$statusNames = @{
0 = "Unlicensed"; 1 = "Licensed (activated)"; 2 = "OOB grace period";
3 = "OOT grace period"; 4 = "Non-genuine grace"; 5 = "Notification (NOT activated)"; 6 = "Extended grace"
}
$products = Get-CimInstance SoftwareLicensingProduct -Filter "PartialProductKey IS NOT NULL" -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like "Windows*" }
if (-not $products) {
Write-Log "No Windows license with a product key found!"
return
}
foreach ($p in $products) {
$state = if ($statusNames.ContainsKey([int]$p.LicenseStatus)) { $statusNames[[int]$p.LicenseStatus] } else { "Unknown ($($p.LicenseStatus))" }
Write-Log "Product: $($p.Name)"
Write-Log "Channel: $($p.ProductKeyChannel) | Partial key: *$($p.PartialProductKey)"
Write-Log "Status: $state"
if ($p.LicenseStatus -eq 1) {
if ($p.GracePeriodRemaining -gt 0) {
$days = [math]::Round($p.GracePeriodRemaining / 1440, 0)
Write-Log "Rearm/KMS window remaining: $days day(s)"
}
Write-Log "License check complete: Windows is activated."
} else {
Write-Log "WARNING: Windows is NOT properly activated!"
}
}Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Windows Server Roles
Report Installed Server Roles with PowerShell
2026-08-17Report DHCP Scope Utilization with PowerShell
2026-08-17Create a DNS A Record with PowerShell
2026-08-17Clear the DNS Server Cache with PowerShell
2026-08-17Find the Largest Files in a Folder with PowerShell
2026-08-17Get Folder Sizes with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.