I want to change the culture of accepted data and errors in my current interactive Powershell session. I am aware of this question powershell : changing the culture of current session and of this question Changing current culture on SuperUser. The main problem that it doesn't work with Powershell 3.0 and 4.0.
PS C:\users\me\Documents> [system.threading.thread]::currentthread.currentculture
LCID Name DisplayName
---- ---- -----------
1049 ru-RU Русский (Россия)
PS C:\users\me\Documents> [system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US"
PS C:\users\me\Documents> [system.threading.thread]::currentthread.currentculture
LCID Name DisplayName
---- ---- -----------
1049 ru-RU Русский (Россия)
UI culture also does not accept new settings. Set-Culture
in total does not work, regardless of whether I'm using admin access or not - anyway, it shouldn't be affected by this, as the effect is only for a single process. The Using-Culture
from MSDN Powershell blog, adapted by SO community, works, but only partially, for example, with current culture of "ru-RU" I am able to get proper date from "6/19/15 2:26:02 PM" string, which is in the "en-US" culture via Using-Culture "en-US" {get-date -date "6/19/15 2:26:02 PM"}
, but receiving an error in another language is not possible: say Using-Culture "en-US" {$null.test='1'}
results in an error with Russian locale, as if the culture was not changed.
This behavior was tested on my local Win7 Professional workstation with Powershell 4.0 installed, and a Windows Server 2012 with Powershell 3.0 installed, which is required to parse wrongly localized date strings. The latter has UI culture of "en-US" and system locale "ru-RU".
So, is changing Powershell session's culture still possible with PS3 and above, and if yes, how? (Or is it bugs again, or change in PS3 that I am not aware of?)