简体   繁体   English

使用Powershell激活Windows 2008 R2 Server

[英]Use Powershell to Activate Windows 2008 R2 Server

如何使用powershell输入密钥然后激活Windows 2008 R2安装?

Try this: How to Activate Windows 7 Through PowerShell 试试这个: 如何通过PowerShell激活Windows 7

  • Step 3: $service= get-wmiObject -query "select * from SoftwareLicensingService" -computername computer Replace "computer" with the computer name. 第3步: $service= get-wmiObject -query "select * from SoftwareLicensingService" -computername computer将“computer”替换为计算机名称。

  • Step 4: Install the license key. 第4步:安装许可证密钥。 The following code adds the Windows activation license to the computer: $service.InstallProductKey($key) and $service.RefreshLicenseStatus() . 以下代码将Windows激活许可证添加到计算机: $service.InstallProductKey($key)$service.RefreshLicenseStatus() Replace $key with your license key for Windows. 用您的Windows许可证密钥替换$key

I've used slmgr utility - as described here: 我使用了slmgr实用程序 - 如下所述:

cscript.exe /B "c:\\windows\\system32\\slmgr.vbs" -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX -ato

And here: 和这里:

I've had this same exact problem on 2008 R2. 我在2008 R2上遇到了同样的问题。 Here's what I did. 这就是我做的。

$all_services = Get-WmiObject -Query "SELECT * FROM SoftwareLicensingService"
$all_services.InstallLicense($key)
$service = Get-WmiObject SoftwareLicensingProduct | Where-Object {$_.PartialProductKey}
$service.Activate()
$all_services.RefreshLicenseStatus()

Now, I'm not sure why $service doesn't have an install method. 现在,我不确定为什么$ service没有安装方法。 There's probably a more efficient way to do this, but the key point is you need to invoke the activate method before refreshing. 可能有一种更有效的方法,但关键是你需要在刷新之前调用activate方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM