SE の雑記

SQL Server の情報をメインに Microsoft 製品の勉強内容を日々投稿

Azure VM の日本語 UI を PowerShell で設定

leave a comment

まだ、設定の練度が甘いですが基本的な作業としてまとめてみたいと思います。
以下も参考になります。
Windows Azure仮想マシンのWindows ServerとVisual Studioの日本語化メモ
Windows Azure 仮想マシン上のWindows Server 2012の日本語化
Windows Azure 仮想マシン上のWindows Server 2012の日本語化は標準手順で OK

以下は、Windows Server 2012 のサンプルになります。

$lpurl = "http://fg.v4.download.windowsupdate.com/msdownload/update/software/updt/2012/10"
$lpfile = "windowsserver2012-kb2607607-x64-jpn_d079f61ac6b2bab923f14cd47c68c4af0835537f.cab"
$wintemp = "C:\Windows\Temp"
$RunOncePath = "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"
$runonce = "Set-WinUILanguageOverride ja-JP;Set-WinSystemLocale 1041;Set-WinHomeLocation 0x7A;restart-computer"
Set-WinUserLanguageList ja-jp,en-US -Force
Start-BitsTransfer -Source $lpurl/$lpfile -Destination $wintemp
Add-WindowsPackage -Online -PackagePath $wintemp\$lpfile
"powershell.exe -ExecutionPolicy RemoteSigned $runonce" | Out-File -FilePath C:WindowsTempSetupLang.cmd -Encoding ascii
Set-ItemProperty -Path $RunOncePath -Name "SetupLang" -Value "C:\Windows\Temp\SetupLang.cmd"
restart-computer

 
言語パックの cab を MS のサイトから BITS でダウンロードして適用をしています。
その後言語系の設定をするためのコマンド群を RunOnce で設定した状態にしています。
そのため再起動後に一度ログインをする必要がありますが、再起動後に初回ログインをした後は日本語の言語設定になっているかと思います。
コントロールパネルから言語を追加した場合には、再起動が必要ないので Add-WindowsPackage をした後は Set-WinUILanguageOverride で UI を設定できそうなのですが、Add-WindowsPackage だけでは再起動をした後に UI 言語設定をする必要がありました。
初回ログインを忘れてしまうと再起動の処理が残ってしまいますので、明示的に以下のように二つに分けて手動で実行してもよいかもしれないですね。

$lpurl = "http://fg.v4.download.windowsupdate.com/msdownload/update/software/updt/2012/10"
$lpfile = "windowsserver2012-kb2607607-x64-jpn_d079f61ac6b2bab923f14cd47c68c4af0835537f.cab"
$wintemp = "C:\Windows\Temp"
Set-WinUserLanguageList ja-jp,en-US -Force
Start-BitsTransfer -Source $lpurl/$lpfile -Destination $wintemp
Add-WindowsPackage -Online -PackagePath $wintemp$lpfile
restart-computer

 

Set-WinUILanguageOverride ja-JP
Set-WinSystemLocale 1041
Set-WinHomeLocation 0x7A
tzutil /s "Tokyo Standard Time"
restart-computer

 
今回は再起動した後のログインを手動で実行して、後続の処理を実行していますが自動ログオン (AutoAdminLogon) を使用することでログインが不要となりますのでこの辺を設定しておくとよいかと思います。
Windows で自動ログオン機能を有効にする方法

  • 自動ログオンを設定し、後続処理を実行
  • 後続処理が実行し終わったら、自動ログオンを解除

というようなレジストリ操作をすれば手動ログインが不要となりますので。
自動ログオンをした場合のスクリプトは以下のようになります。

$lpurl = "http://fg.v4.download.windowsupdate.com/msdownload/update/software/updt/2012/10"
$lpfile = "windowsserver2012-kb2607607-x64-jpn_d079f61ac6b2bab923f14cd47c68c4af0835537f.cab"
$wintemp = "C:\Windows\Temp"
$RunOncePath = "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"
$AutoLogonPath = "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
$AdminUser = "Administrator アカウント"
$adminpassword = "パスワード"
$runonce = @"
Set-WinUILanguageOverride ja-JP
Set-WinSystemLocale 1041
Set-WinHomeLocation 0x7A
tzutil /s "Tokyo Standard Time"
Set-ItemProperty -Path "$AutoLogonPath" -Name "AutoAdminLogon" -Value "0"
Remove-ItemProperty -Path "$AutoLogonPath" -Name "DefaultUserName"
Remove-ItemProperty -Path "$AutoLogonPath" -Name "DefaultPassword"
restart-computer
"@
Set-WinUserLanguageList ja-jp,en-US -Force
Start-BitsTransfer -Source $lpurl/$lpfile -Destination $wintemp
Add-WindowsPackage -Online -PackagePath $wintemp\$lpfile
$runonce | Out-File -FilePath C:\Windows\Temp\SetupLang.ps1 -Encoding ascii
Set-ItemProperty -Path $RunOncePath -Name "SetupLang" -Value "powershell.exe -ExecutionPolicy RemoteSigned -file C:\Windows\Temp\SetupLang.ps1"
Set-ItemProperty -Path $AutoLogonPath -Name "AutoAdminLogon" -Value "1"
Set-ItemProperty -Path $AutoLogonPath -Name "DefaultUserName" -Value $AdminUser
Set-ItemProperty -Path $AutoLogonPath -Name "DefaultPassword" -Value $adminpassword
restart-computer

 
なお、Windows Server 2012 R2 の場合は以下の URL から言語パックがダウンロードできます。

$lpurl = "http://fg.v4.download.windowsupdate.com/d/msdownload/update/software/updt/2013/09"
$lpfile = "lp_3d6c75e45f3247f9f94721ea8fa1283392d36ea2.cab"

MS のサイトから言語パックをダウンロードできない場合は、MSDN や TechNet サブスクリプションから言語パックの ISO をダウンロードして、Azure Storage の Public BLOB に保存して、それをダウンロード先として指定してもよいかと思います。
ようこそ画面と新しいユーザーアカウントの設定がコマンドベースでどうやるかがつかめておらず、そこは手動で実行する必要がありますが。
image
日本語設定にするスクリプトはきちんと整備しておきたいですね。
なお、タイムゾーンも変更する必要がある場合は、Script to change the time zone in Windows 7 or Windows 8 (PowerShell) も組み合わせる必要が出てくるかと。
International Settings Cmdlets in Windows PowerShell も見ておくとよさそうですね。

Share

Written by Masayuki.Ozawa

11月 24th, 2013 at 2:09 pm

Leave a Reply