Skip to content

Instantly share code, notes, and snippets.

@GitHub30
Forked from sunnyone/PowerShellUICulture.ps1
Last active October 1, 2022 12:20
Show Gist options
  • Save GitHub30/b761f402849818cc53aa22030c72c8e3 to your computer and use it in GitHub Desktop.
Save GitHub30/b761f402849818cc53aa22030c72c8e3 to your computer and use it in GitHub Desktop.
Changing PowerShell UICulture
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