DCM Scripts – Checking Windows Activation Status

My last script was, out of necessity, a rather laborious one. Using a VBScript to check a status, generating a file from its output, reading files, creating objects and properties etc. Luckily enough, checking Windows activations (and checking Office activations on Windows 8.1) is considerably easier.

There is a WMI class called SoftwareLicensingProduct which is where Windows just happens store the activation status for itself and on Windows 8, for Office as well.

To detect the activation status for Windows itself, use this:

$WindowsActivationStatus = Get-CimInstance SoftwareLicensingProduct -Filter "Description LIKE '%KMSCLIENT%' and Name LIKE '%Windows%'" | select ID, Description, LicenseStatus, Name, GenuineStatus

if ($WindowsActivationStatus.LicenseStatus -eq "1") {
 echo "Windows is Activated"
 else {
 echo "Windows is not activated"

And use this as a remediation script:

c:\windows\system32\cscript.exe c:\windows\system32\slmgr.vbs /skms address.of.kms.server.domain.name:1688
c:\windows\system32\cscript.exe c:\windows\system32\slmgr.vbs /ato

Strictly speaking, the first line shouldn’t be necessary if you’ve set KMS up properly but including it does at least force the machine to look at the correct server for activation.

Set up a compliance rule to look for a string which says “Windows is activated”, create a new baseline or add it to a new one and deploy to a collection.



Leave a Reply

Your email address will not be published. Required fields are marked *