在内部网络中能够及时的了解Windows系统激活状态可以有效的保持系统有效更新和正版化,下面是通过PowerShell 获取Windows 系统激活状态

$ActivationStatus = Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" | Where-Object { $_.PartialProductKey } | Select-Object LicenseStatus       

        $LicenseResult = switch($ActivationStatus.LicenseStatus){
        0    {"Unlicensed"}
        1    {"Licensed"}
        2    {"OOBGrace"}
        3    {"OOTGrace"}
        4    {"NonGenuineGrace"}
        5    {"Not Activated"}
        6    {"ExtendedGrace"}
        default {"Unknown"}
        }
$LicenseResult