Share via


ConfigMgr Compliance Baseline to verify Windows Activation Status

In most environments we are running KMS and don’t tend to think to often about our activation status but with more and more systems coming and going with BYOD and god knows what else your technicians are doing throughout your enterprise its good to have some piece of mind from a ConfigMgr perspective and validate that your systems are indeed licensed properly.  In this post ill provide the Powershell code for detection and remediation utilizing the KMS Client Setup Keys from https://technet.microsoft.com/en-us/library/jj612867(v=ws.11).aspx as well as the Compliance Baseline to import and implement for a few operating system types.  Feel free to extend for your supported operating systems.

Discovery Script:

#Windows Activation
if((cscript "$env:SystemRoot\system32\slmgr.vbs" -dli all) -Contains "License Status: Licensed")
{
Write-Host $False
}
else
{
Write-Host $True
}

Remediation Script:

# Determine OS and Set KMS Client key

switch ((gwmi -Class Win32_OperatingSystem).Caption) {
"Microsoft Windows Server 2008 R2 Enterprise" {$License = "489J6-VHDMP-X63PK-3K798-CPX3Y"; break}
"Microsoft Windows Server 2008 R2 Standard" {$License = "YC6KT-GKW9T-YTKYR-T4X34-R7VHC"; break}
"Microsoft Windows Server 2008 R2 Datacenter" {$License = "74YFP-3QFB3-KQT8W-PMXWJ-7M648"; break}
"Microsoft Windows Server 2012 R2 Standard" {$License = "D2N9P-3P6X9-2R39C-7RTCD-MDVJX";    break}
"Microsoft Windows Server 2012 R2 Datacenter" {$License = "W3GGN-FT8W3-Y4M27-J84CP-Q3VJ9";    break}
"Microsoft Windows Server 2016 Standard" {$License = "WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY";    break}
"Microsoft Windows Server 2016 Datacenter" {$License = "CB7KF-BWN84-R7R2Y-793K2-8XDDG";    break}
"Microsoft Windows 10 Enterprise" {$License = "NPPR9-FWDCX-D2C8J-H872K-2YT43";    break}
default {$License = "Unknown"}
}
#Windows Activation
If($License -ne "Unknown"){
Write-Host "Activating Windows..."
cscript "$env:SystemRoot\system32\slmgr.vbs" -ipk $License //nologo
cscript "$env:SystemRoot\system32\slmgr.vbs" -ato //nologo
}

Compliance Baseline:

Microsoft-Volume-License-Activation

If you have any feedback or want to provide more captions from Win32_OperatingSystem.Caption please comment with your additions and ill update the post.

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in theTerms of Use .