【生产实测有效】Windows命令行查看激活状态脚本
- Windows查看激活状态关键代码
通过windows server 自带的PowerShell来执行
Get-WmiObject SoftwareLicensingProduct | Select-Object -Property Description, LicenseStatus | findstr "Operating System"|findstr "1$"Get-WmiObject SoftwareLicensingProduct | Where-Object { $_.LicenseStatus -eq 1 } | Select-Object -ExpandProperty Description
Windows Operating System - Windows® 7, RETAIL channel
- 写出来的巡检脚本
如果License状态是正常的,就返回1,否则返回0
$res = Get-WmiObject SoftwareLicensingProduct | Where-Object { $_.LicenseStatus -eq 1 } | Select-Object -ExpandProperty Descriptionif ($res -ne $null)
{Write-Output "LicenseStatus 1"
}
else
{Write-Output "LicenseStatus 0"
}