Culture and UI culture in PowerShell
Read, set and list cultures in PowerShell, and change the language of the help.
PowerShell separates the culture (date, number, currency formats and sort order) from the UI culture (language of messages and help). The commands below read, set and list these cultures.
Read and set the culture
get-culture
set-culture en-US
$PSUICulture
List the culture types
[Enum]::GetValues([System.Globalization.CultureTypes])
List the cultures
[System.Globalization.CultureInfo]::GetCultures( [System.Globalization.CultureTypes]::AllCultures )
Get a culture
A culture can be identified by its LCID (1033 is en-US) or by its name.
$culture = [System.Globalization.CultureInfo]::GetCultureInfo(1033)
$culture = [System.Globalization.CultureInfo]::GetCultureInfo('en-US')
Set the session culture with a function
The following function applies one culture to both the culture and the UI culture of the current thread.
function Set-Culture([System.Globalization.CultureInfo] $culture) { [System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture ; [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture } ; Set-Culture en-US ; [system.threading.thread]::currentthread.currentculture
Change the language of the help
To display help in another language, change the UI culture, then download the matching help files.
[Threading.Thread]::CurrentThread.CurrentUICulture = 'fr-FR'; Get-Help Get-Process
Update-Help -UICulture en-US
[Threading.Thread]::CurrentThread.CurrentUICulture = 'en-US';
Notes
- The UI culture and the culture are independent: changing one does not change the other.
- The behaviour of the UI culture is discussed on Stack Overflow: PowerShell UICulture vs Windows setting.