当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 检查 Active Directory 计算机上的 Windows 激活状态

作者:精品下载站 日期:2024-12-14 23:27:22 浏览:17 分类:玩电脑

检查 Active Directory 计算机上的 Windows 激活状态


在本文中,我们将展示如何确保您的 Windows 副本在计算机上激活,并使用 PowerShell 检查 Active Directory 域网络中所有计算机的 Windows 激活状态。

如何检查Windows是否已激活?

首先,我们来看看如何检查计算机上的Windows激活状态。您可以使用“设置”应用查看 Windows 激活状态(在现代 Windows 10 和 Windows 11 版本中)。

  • 在 Windows 10 和 Windows Server 2022/2019/2016 上,转到设置 -> 更新和安全 -> 激活(或运行

    ms-settings:activation

    用于快速访问 ms-settings 的 URI 命令)

  • 在 Windows 11 中,打开设置 -> 系统 -> 激活

今天,微软提供从最新 Windows 10 版本免费升级到 Windows 11 的服务。如果您的 Microsoft 帐户中注册了具有 Windows 10 数字许可证的计算机,则升级到 Windows 1 后,计算机将自动检查数字许可证并激活 Windows。

您可能会看到以下激活状态之一:

  • Windows is activated using your organization’s activation service

    - 这意味着您的 Windows 副本已在公司 KMS 服务器上激活(KMS 激活常见问题解答);

    [玩转系统] 检查 Active Directory 计算机上的 Windows 激活状态

  • Windows is activated with a digital license

    - 您的 Windows 副本是使用未链接到 Microsoft 用户帐户的数字许可证激活的;

    [玩转系统] 检查 Active Directory 计算机上的 Windows 激活状态

  • Windows is activated with a digital license linked to your Microsoft account
  • Not Activated - Windows reported that no product key was found on your device. Error code: 0xC004F214

    - Windows 安装时没有产品密钥且未激活。

您可以从命令提示符激活 Windows。为此,请使用 SLMgr.vbs 脚本,该脚本允许管理 Windows 许可证和激活。以管理员身份运行命令提示符 (cmd) 并输入以下命令:

slmgr /xpr

[玩转系统] 检查 Active Directory 计算机上的 Windows 激活状态

几秒钟后会出现一个带有“

The machine is permanently activated

” 消息出现。

如果 Windows 未激活,您将看到以下消息:

Windows is in Notification mode

提示。 如果您想在命令提示符控制台中显示激活状态,请使用此命令

cscript slmgr.vbs -xpr

使用 PowerShell 检查 Windows 激活

您可以使用 PowerShell 获取本地或远程计算机上的 Windows 激活信息。运行以下命令从 CIM (WMI) 获取数据:

Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" | where { $_.PartialProductKey } | select Description, LicenseStatus

可能的 LicenseStatus 值:

  • 0 - 未经许可

  • 1 - 已获得许可

  • 2 - OOBGrace

  • 3 - OOTGrace - 计算机配置已更改,无法自动激活,或超过180天

  • 4 - NonGenuineGrace

  • 5 - 通知 - Windows 试用期结束

  • 6 - ExtendedGrace(您可以使用以下命令多次延长 Windows 评估期)

    slmgr /rearm

    命令或将评估转换为完整版本)

下面的截图显示

 LicenseStatus = 1

。这意味着 Windows 是使用零售产品密钥(Windows(R) 操作系统、零售渠道)激活的。

[玩转系统] 检查 Active Directory 计算机上的 Windows 激活状态

要获取远程计算机的激活状态,请在 -ComputerName 参数中指定其名称:

Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" -ComputerName mun-srv03 |where { $_.PartialProductKey } | select Description, LicenseStatus

VOLUME_KMSCLIENT channel

字符串表示计算机已在 KMS 服务器上激活。

[玩转系统] 检查 Active Directory 计算机上的 Windows 激活状态

或者使用 Enter-PSSession 或 Invoke-Command WinRM cmdlet 访问远程计算机。

使用 PowerShell 获取 AD 计算机上的 Windows 激活状态

您可以使用 PowerShell 远程获取 Active Directory 域中 Windows 桌面计算机和 Windows Server 主机的激活状态。您可以查看下面的脚本示例。

要获取域中的计算机列表,请使用 Active Directory for PowerShell 模块中的 Get-ADComputer cmdlet。此 PowerShell 脚本依次检查 Active Directory 中每台计算机的可用性(使用 Test-NetConnection 的简单 ICMP ping),获取安装在这些计算机上的操作系统的内部版本和版本以及 Windows 激活状态。

enum Licensestatus{
Unlicensed = 0
Licensed = 1
Out_Of_Box_Grace_Period = 2
Out_Of_Tolerance_Grace_Period = 3
Non_Genuine_Grace_Period = 4
Notification = 5
Extended_Grace = 6
}
$Report = @()
$ADComps = Get-ADComputer -Filter {enabled -eq "true" -and OperatingSystem -Like '*Windows*'}
Foreach ($comp in $ADComps) {
If ((Test-NetConnection $comp.name -WarningAction SilentlyContinue).PingSucceeded -eq $true){
$activation_status= Get-CimInstance -ClassName SoftwareLicensingProduct -ComputerName $comp.name -Filter "Name like 'Windows%'" |where { $_.PartialProductKey } |  select PSComputerName, @{N=’LicenseStatus’; E={[LicenseStatus]$_.LicenseStatus}}
$windowsversion= Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $comp.name| select Caption, Version
$objReport = [PSCustomObject]@{
ComputerName = $activation_status.PSComputerName
LicenseStatus= $activation_status.LicenseStatus
Version = $windowsversion.caption
Build = $windowsversion.Version
}
}
else {
$objReport = [PSCustomObject]@{
ComputerName = $comp.name
LicenseStatus = "Computer offline"
}
}
$Report += $objReport
}
$Report |Out-GridView 

该脚本可在我的 GitHub 存储库中找到:https://github.com/maxbakhub/winposh/blob/main/ActiveDirectory/AD_Computers_Check_Windows_Activation_Status.ps1

有关域计算机上的 Windows 激活状态的信息以 Out-GridView 表的形式显示。或者您可以将其导出到 CSV 文件(

Export-Csv -Path .\ad_windows_activation_report.csv -NoTypeInformation

)。

[玩转系统] 检查 Active Directory 计算机上的 Windows 激活状态

您可以找到类似的 PowerShell 脚本来检查域计算机上的 Microsoft Office 激活状态。

因此,您可以快速找到域中计算机上所有未激活(未经许可)的 Windows 副本。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯