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

练习代码二十年

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

阅读量:303

点赞量:5

问AI
开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 } }