How to Get Windows Activation Status Using PowerShell

To get the Windows activation status with PowerShell, query the SoftwareLicensingProduct class for Windows and read LicenseStatus. A value of 1 means Windows is activated:

Get-CimInstance -ClassName SoftwareLicensingProduct -Filter "ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f' AND PartialProductKey IS NOT NULL" |
    Select-Object -Property Name, LicenseStatus

It works without admin rights in PowerShell 7 and 5.1. Below I turn the number into readable text, build a quick yes-or-no check, query remote PCs and compare it with slmgr.

Get the activation status

The ApplicationID in the filter is the one Windows uses, so Office and other licensed products stay out of the results. LicenseStatus is a number, so I map it to text:

$statusText = @{
    0 = 'Unlicensed'; 1 = 'Licensed'; 2 = 'Initial grace period'; 3 = 'Additional grace period'
    4 = 'Non-genuine grace period'; 5 = 'Notification'; 6 = 'Extended grace period'
}
$windows = Get-CimInstance -ClassName SoftwareLicensingProduct -Filter "ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f' AND PartialProductKey IS NOT NULL"

$windows | Select-Object -Property Name, @{ Name = 'Status'; Expression = { $statusText[[int]$_.LicenseStatus] } }

Output:

Name                           Status
----                           ------
Windows(R), Enterprise edition Licensed
PowerShell get Windows activation status
My Windows 11 Enterprise PC is licensed (PowerShell 7)

Windows PowerShell 5.1 returns exactly the same result:

Windows activation status in Windows PowerShell 5.1
The same query in Windows PowerShell 5.1 (Windows PowerShell 5.1)

I selected only the name and status on purpose. The class also has a PartialProductKey property with the last five characters of the key, which I don’t share.

If you need the key itself, see retrieving your Windows product key.

What the LicenseStatus values mean

ValueStatusWhat to do
0UnlicensedActivate Windows or enter a valid key
1LicensedNothing, Windows is activated
2Initial grace periodActivate before the grace period ends
3Additional grace periodUsually after a hardware change, activate again
4Non-genuine grace periodCheck the license source
5NotificationWindows shows activation reminders until you activate
6Extended grace periodActivate before it ends

Return a simple True or False

In scripts I don’t want a table, just an answer. This function returns True when Windows is licensed:

function Test-WindowsActivation {
    $filter = "ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f' AND PartialProductKey IS NOT NULL"
    $product = Get-CimInstance -ClassName SoftwareLicensingProduct -Filter $filter
    [bool]($product | Where-Object -Property LicenseStatus -EQ 1)
}

"Windows is activated: $(Test-WindowsActivation)"

Output:

Windows is activated: True
PowerShell Test-WindowsActivation function
A reusable activation check (PowerShell 7)

Use it in an if statement, or in a compliance check before you deploy software. For other system details, see getting BIOS information with PowerShell.

Check activation on remote computers

Get-CimInstance takes -ComputerName, so the same query works across many PCs. It uses WinRM on the remote computers:

$statusText = @{
    0 = 'Unlicensed'; 1 = 'Licensed'; 2 = 'Initial grace period'; 3 = 'Additional grace period'
    4 = 'Non-genuine grace period'; 5 = 'Notification'; 6 = 'Extended grace period'
}
$filter = "ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f' AND PartialProductKey IS NOT NULL"
Get-CimInstance -ComputerName 'NYC-PC01', 'DAL-PC02' -ClassName SoftwareLicensingProduct