Last active
June 8, 2017 08:04
-
-
Save MasayukiOzawa/417c3e541b51ddea3e0399c0f97d87d8 to your computer and use it in GitHub Desktop.
英語 OS に日本語の言語パックをインストール
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Install-JapaneseLanguagePack | |
{ | |
Param( | |
[parameter(mandatory=$true)] | |
$AdminUser = "", | |
[parameter(mandatory=$true)] | |
$AdminPassword = "", | |
[parameter(mandatory=$true)] | |
[ValidateSet("2012" , "2012R2", "2016")] | |
$OSVersion = "" | |
) | |
try{ | |
$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" | |
# | |
$lpuri = switch($OSVersion) | |
{ | |
"2012" {"http://fg.v4.download.windowsupdate.com/msdownload/update/software/updt/2012/10/windowsserver2012-kb2607607-x64-jpn_d079f61ac6b2bab923f14cd47c68c4af0835537f.cab"} | |
"2012R2" {"http://fg.v4.download.windowsupdate.com/d/msdownload/update/software/updt/2013/09/lp_3d6c75e45f3247f9f94721ea8fa1283392d36ea2.cab"} | |
"2016" {"http://fg.v4.download.windowsupdate.com/c/msdownload/update/software/updt/2016/09/lp_9a666295ebc1052c4c5ffbfa18368dfddebcd69a.cab"} | |
default{return} | |
} | |
Set-WinUserLanguageList ja-jp,en-US -Force | |
Invoke-WebRequest -Uri $lpuri -OutFile (Join-Path -Path $wintemp -ChildPath "lp.cab") | |
Add-WindowsPackage -Online -PackagePath (Join-Path -Path $wintemp -ChildPath "lp.cab") | |
Remove-Item (Join-Path -Path $wintemp -ChildPath "lp.cab") | |
$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" | |
Remove-Item $(Join-Path -Path $wintemp -ChildPath "SetupLang.ps1") | |
Start-Sleep -Seconds 20 | |
Restart-Computer -Force | |
"@ | Out-File -FilePath (Join-Path -Path $wintemp -ChildPath "SetupLang.ps1") -Encoding ascii | |
Set-ItemProperty -Path $RunOncePath -Name "SetupLang" -Value "powershell.exe -ExecutionPolicy RemoteSigned -file $(Join-Path -Path $wintemp -ChildPath '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 -Force | |
}catch [Exception]{ | |
"{0}`n{1}" -f $Error[0].ScriptStackTrace, $Error[0].Exception | Set-Content -Path (Join-Path -Path $wintemp -ChildPath "error.log") | |
$Error[0] | fl -Force | |
} | |
} | |
Install-JapaneseLanguagePack -AdminUser "Administrator" -AdminPassword "<パスワード>" -OSVersion 2016 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment