powershellcultureinfoculture

PowerShell: How to set culture?


I tried to Set-Culture -CultureInfo vi-VN but Powershell was not changed to my setted Culture.

I tested by open Powershell ISE and seen my setted Culture was changed successful.

How to make Powershell changes to my setted Culture?


Solution

  • Assuming you've started a new session (see below):

    You may have run into a Windows PowerShell bug, present as of v5.1.18362.628):

    Changing to culture vi-VN (Vietnamese (Vietnam), LCID 1066), specifically[1], doesn't seem to work in Windows PowerShell (v5.1-) in console windows[2] (whereas it does work in the obsolescent PowerShell ISE, as you state).

    Note: The change does take effect for the current user account in general, but not in Windows PowerShell console windows.

    PowerShell [Core] 6+ is not affected.


    As for a potential fix: Windows PowerShell is no longer in active development, so only critical fixes are being implemented. You can report Windows PowerShell bugs in the relevant UserVoice forum.


    Generally speaking:


    [1] Not sure if other cultures are affected as well.

    [2] Running in Windows Terminal doesn't help either. This suggests that the bug is inside the ConsoleHost PowerShell host inside of which console-based PowerShell sessions run (whereas the ISE implements its own host, Windows PowerShell ISE Host), as reflected in $HOST.