【AWS】EC2に「Windowsはライセンス認証されていません」を解決しました
はじめに
AWSのWindows AMIを違うVPC内に立てたら、急遽「Windowsはライセンス認証されていません」という表示が出てしまいました。
その解決策を備忘録として残したいと思います。
事象
下記のように、EC2を別のVPC内に立てたら、「Windowsはライセンス認証されていません」が表示されました。
解決策
「Windows」→「Windows Powershell」の「管理者として実行」を押下します。
下記のコマンドを入力します。
PS C:\> Import-Module "C:\ProgramData\Amazon\EC2-Windows\Launch\Module\Ec2Launch.psd1"
PS C:\> Add-Routes
PS C:\> Set-Activationsettings
PS C:\> cscript "${env:SYSTEMROOT}\system32\slmgr.vbs" /ato
すると、「Windowsがライセンス認証されています」と変更され、無事に解決できました。
バッチで対応
AutoScaling時に、Windowsライセンス認証失敗事象がもし発生してしまったら、非常に困るので、そのためにバッチを作成いたしました。
まずはps1を作成しました。
Windows_lisence_Activation.ps1
Import-Module "C:\ProgramData\Amazon\EC2-Windows\Launch\Module\Ec2Launch.psd1"
Add-Routes
Set-Activationsettings
cscript "${env:SYSTEMROOT}\system32\slmgr.vbs" /ato
echo "Success" | Out-File Windows_lisence.log
続いてbatを作成します。
Windows_lisence_Activation.bat
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "C:\XXXXXXXX\Windows_lisence_Activation.ps1 -Verb runas"
参考資料
Author And Source
この問題について(【AWS】EC2に「Windowsはライセンス認証されていません」を解決しました), 我々は、より多くの情報をここで見つけました https://qiita.com/hyj624117615/items/3f3cc9353bc583a1881e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .