メインコンテンツまでスキップ

Windows 11 プロダクトキーリセットガイド: PowerShell自動化

· 約7分

この包括的なガイドでは、PowerShellコマンドを使用してWindows 11のプロダクトキーを管理・リセットする方法を詳しく説明します。このプロセスは、既存のライセンスデータをクリアし、システムのBIOSから直接取得した新しいプロダクトキーを適用して、正しく再アクティベーションを行う必要があるユーザー向けに設計されています。

⚠️ セキュリティ警告: これらのスクリプトを実行すると、システムのライセンスコンポーネントを変更することになります。細心の注意を払って進めてください。管理者権限があることを確認し、実行前に使用するプロダクトキーを検証してください。誤ったキーはシステムのアクティベーション状態に影響を与える可能性があります。

前提条件

開始する前に、以下を確認してください。

  1. BIOS/UEFI設定にアクセスしてキーを確認できる、有効なWindows 11インストール環境。
  2. Windows 11マシンでの管理者権限。

1. BIOSからプロダクトキーを取得する(自動)

変更を加える前に、Windowsライセンスサービス内に保存されている現在または元のOEMプロダクトキーを取得しておくことが重要です。これは参照用や復元用に必要になる場合があります。

昇格されたPowerShellセッションで次のコマンドを実行し、キーを表示します。

(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey

操作: コンソールに表示された出力をコピーします。これが参照用の元のプロダクトキーです。

2. 手動でのキー管理手順(理解を深めるため)

以下は、スクリプト内で使用される個々のコマンドの説明です。

A. 現在のライセンスステータスのクリア

このコマンドを使用して、現在インストールされているプロダクトキーをWindowsアクティベーションサービスから削除し、アクティブなライセンスステータスを事実上クリアします。

slmgr.vbs /upk

説明: /upkスイッチは、現在インストールされているプロダクトキーをアンインストールするために使用されます。

B. レジストリからキーをクリア(セキュリティ対策)

システムレジストリに残るプロダクトキー情報を最小限にするため、このコマンドを実行します。

slmgr.vbs /cpky

説明: このコマンドは、システムレジストリに保存されている残留プロダクトキー情報を消去します。これは、権限のないユーザーがライセンス情報を容易に取得できないようにするためのセキュリティ対策です。

C. 新しいプロダクトキーの適用とアクティベーション

新しいプロダクトキーを入手したら、slmgr.vbsを使ってそれをインストールし、即座にアクティベーションをトリガーします。

slmgr.vbs /ipk YOUR_NEW_PRODUCT_KEY
slmgr.vbs /ato

YOUR_NEW_PRODUCT_KEYを実際の25文字のWindowsプロダクトキーに置き換えてください。プレースホルダーのテキストのままコマンドを実行しないでください。

説明: /ipk <product-key>は指定されたプロダクトキーをシステムにインストールします。/atoは、新しくインストールされたキーを使ってただちにWindowsをアクティベートしようとします。

D. アクティベーションタイマーのリセット(任意)

アクティベーションの試用期間に関する問題が発生している場合、または既存のアクティベーションタイマーをリセットしたい場合は、次のコマンドを実行します。

slmgr.vbs /rearm

説明: /rearmコマンドはアクティベーションタイマーをリセットします。これは、最近ハードウェアを変更した場合や、既存の試用期間の問題をリセットする必要がある場合に役立ちます。

3. 包括的な自動化スクリプト

このセクションでは、元のキーの取得、古いライセンスのクリア、BIOSから直接取得した新しいキーの適用という一連のプロセス全体を自動化する、包括的なPowerShellスクリプトについて説明します。

使用手順: -1. 以下に示す完全なスクリプトをファイル(例: Reset-Win11KeyFromBIOS.ps1)に保存します。 -2. $NewProductKey内のYOUR_NEW_PRODUCT_KEYプレースホルダーを、インストールしたい実際のプロダクトキーに置き換えます。 -3. このスクリプトを昇格されたPowerShellウィンドウから実行します。 -4. スクリプトは、BIOSデータを反映するシステム構造からのキー情報の読み取りを含め、すべての手順を自動的に処理します。

3.1 キー取得スクリプト

<#
.SYNOPSIS
Automates the full Windows 11 Product Key reset process by retrieving a key
from the system licensing service (simulating BIOS/hardware retrieval),
clearing old licenses, and applying a new product key for activation.

.DESCRIPTION
This script performs the following sequence:
1. Retrieves the original OEM product key from the SoftwareLicensingService WMI class.
2. Uninstalls the current product key (/upk).
3. Clears residual license information from the registry (/cpky).
4. Applies the new product key (/ipk) and attempts activation (/ato).
5. Offers an optional command to reset activation timers (/rearm).

.NOTES
Requires running PowerShell as an Administrator.
Ensure you have a valid product key ready for the /ipk step, although this script focuses on the cleanup/activation flow after key retrieval simulation.
#>

Write-Host "==============================================================" -ForegroundColor Yellow
Write-Host "--- Starting Automated Windows 11 Product Key Reset ---" -ForegroundColor Yellow
Write-Host "==============================================================" -ForegroundColor Yellow

# --- Configuration Variables ---
# Replace this placeholder with the actual product key you want to install.
$NewProductKey = "YOUR_NEW_PRODUCT_KEY"

Write-Host "`n[STEP 1/6] Retrieving Original Product Key (Reference)..." -ForegroundColor Cyan
try {
$OriginalKey = (Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey
Write-Host "Successfully retrieved Original Key. Displaying key for reference:" -ForegroundColor Green
Write-Host $OriginalKey
} catch {
Write-Host "Error retrieving original key. Continuing with license reset..." -ForegroundColor Red
$OriginalKey = "N/A (Error)"
}

# 2. Clear Current License Status
Write-Host "`n[STEP 2/6] Clearing Current License from Activation Status (/upk)..." -ForegroundColor Cyan
try {
slmgr.vbs /upk
Write-Host "Current license successfully uninstalled." -ForegroundColor Green
} catch {
Write-Host "Warning: Could not execute slmgr /upk. Error details: $($_.Exception.Message)" -ForegroundColor Red
}

# 3. Clear Key from Registry (Security Measure)
Write-Host "`n[STEP 3/6] Clearing License Key from Registry (/cpky)..." -ForegroundColor Cyan
try {
slmgr.vbs /cpky
Write-Host "License key successfully cleared from the registry." -ForegroundColor Green
} catch {
Write-Host "Warning: Could not execute slmgr /cpky. Error details: $($_.Exception.Message)" -ForegroundColor Red
}

# 4. Apply New Product Key and Activate
Write-Host "`n[STEP 4/6] Installing New Product Key ($NewProductKey) and Attempting Activation (/ipk & /ato)..." -ForegroundColor Cyan
try {
if ($NewProductKey -eq "YOUR_NEW_PRODUCT_KEY") {
throw "Replace the YOUR_NEW_PRODUCT_KEY placeholder before running the activation step."
}

Write-Host "Installing key..."
slmgr.vbs /ipk $NewProductKey
Write-Host "Attempting activation..."
slmgr.vbs /ato
Write-Host "Installation and activation command executed." -ForegroundColor Green
} catch {
Write-Host "FATAL ERROR during key installation or activation: $($_.Exception.Message)" -ForegroundColor Red
}

# 5. Optional: Reset Activation Timers
Write-Host "`n[STEP 5/6] Optional: Resetting Activation Timers (/rearm)..." -ForegroundColor Cyan
$rearmChoice = "N" # Set to 'Y' to execute the rearm command
if ($rearmChoice -ceq "Y") {
Write-Host "Executing /rearm..."
slmgr.vbs /rearm
Write-Host "Activation timers have been reset." -ForegroundColor Green
} else {
Write-Host "Skipping activation timer reset as requested." -ForegroundColor Yellow
}

Write-Host "`n==============================================================" -ForegroundColor Yellow
Write-Host "--- Automation Script Complete ---" -ForegroundColor Yellow
Write-Host "Review the output above for status messages." -ForegroundColor Yellow
Write-Host "==============================================================" -ForegroundColor Yellow