Monthly Archive

Categories

Testing Windows activation

Testing Windows activation from PowerShell involves a little dive into CIM (WMI).

At its simplest a function like this

function test-activation {

$ta = Get-CimInstance -ClassName SoftwareLicensingProduct -Filter "PartialProductKey IS NOT NULL" |
Where-Object -Property Name -Like "Windows*"

if ($ta.LicenseStatus -eq 1) {$true} else {$false}
}

 

Checks the SoftwareLicensingProduct class for instances with a Partial product key. Where-Object filters on the Name of the product. It has to start with Windows.

 

If the LicenseStatus equals 1 then Windows is activated – otherwise it isn’t

Comments are closed.