-
-
Save GitHub30/b761f402849818cc53aa22030c72c8e3 to your computer and use it in GitHub Desktop.
Changing PowerShell UICulture
This file contains hidden or 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
PS C:\Users\Admin> [Threading.Thread]::CurrentThread.CurrentUICulture | |
LCID Name DisplayName | |
---- ---- ----------- | |
1041 ja-JP 日本語 (日本) | |
# example: Set-PowerShellUICulture -Name "en-US" | |
function Set-PowerShellUICulture { | |
param([Parameter(Mandatory=$true)] | |
[string]$Name) | |
process { | |
$culture = [System.Globalization.CultureInfo]::CreateSpecificCulture($Name) | |
$assembly = [System.Reflection.Assembly]::Load("System.Management.Automation") | |
$type = $assembly.GetType("Microsoft.PowerShell.NativeCultureResolver") | |
$field = $type.GetField("m_uiCulture", [Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Static) | |
$field.SetValue($null, $culture) | |
} | |
} | |
PS C:\Users\Admin> [Threading.Thread]::CurrentThread.CurrentUICulture | |
LCID Name DisplayName | |
---- ---- ----------- | |
1033 en-US English (United States) | |
# example: Set-PowerShellUICulture -Name "ja-JP" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment