请问有办法查询 Windows AD 内的电脑是否未激活/盗版/指定版本OS吗?

请问有办法查询 Windows AD 内的电脑是否未激活/盗版/指定版本OS吗?

阅读 2.4k
1 个回答

开PowerShell控制台(管理员身份运行)。
用这个PowerShell脚本:


Import-Module ActiveDirectory

$Computers = Get-ADComputer -Filter * -Property *

foreach ($Computer in $Computers) {
    $ComputerName = $Computer.Name
    $OSVersion = Invoke-Command -ComputerName $ComputerName -ScriptBlock { (Get-WmiObject -Class Win32_OperatingSystem).Caption }
    $ActivationStatus = Invoke-Command -ComputerName $ComputerName -ScriptBlock { (cscript //Nologo slmgr.vbs /dli | Out-String) -match "License Status: (.*)" }
    
    if ($ActivationStatus -match "Licensed") {
        $ActivationStatus = "Activated"
    } else {
        $ActivationStatus = "Not Activated"
    }

    [PSCustomObject]@{
        ComputerName = $ComputerName
        OSVersion = $OSVersion
        ActivationStatus = $ActivationStatus
    }
}
推荐问题
logo
Microsoft
子站问答
访问
宣传栏