I am able to use Set-Culture
(Powershell as Admin) to set the Current Culture to "en-DE"
which is English (Germany). However, when I run the different PS commands to view the Current Culture, I am still getting en-US
. I checked my Region (Format) and Location as well.
Do I have to change the system locale as well to Germany (German) ?
This is causing an error in an application, because the datetime format is different from en-DE to en-US and causing the date to be read incorrectly.
When I Set-Culture
to de-DE
, everything appears to be in working order.
I make sure to run Powershell Console as Administrator, Set-Culture
, close console. Open Powershell and run Get-Culture
, [CultureInfo]::CurrentCulture
, [CultureInfo]::CurrentUICulture
and a few more to check and and still getting en-US
Note: Use of
en-DE
as a culture identifier - i.e., mixing languageen
(English) with normally unrelated region/countryDE
(Germany) - requires Windows 10 with release channel1607
or later or Windows Server 2016, according to Microsoft.However, there's a bug that prevents use of such mixed cultures, observed on Windows 10 Pro (64-bit; Version 1709, OS Build: 16299.371)
While you can successfully set such mixed-culture values with
Set-Culture
, subsequent sessions do not recognize it and fall back toen-US
(as reflected in$PSCulture
,Get-Culture
and[cultureinfo]::currentCulture
)Set-Culture
).The rest of this answer discusses persistently setting the current user's culture in general, irrespective of the bug.
Set-Culture
- via the registry - sets the culture for future PowerShell sessions (only), not (also) for the current session.Get-Culture
, by contrast, only ever reports the current session's culture at session-startup time. That is, if you change the culture during a session (see below), it will not be reflected inGet-Culture
.In order to also apply the newly set culture to the current session, run the following in addition to the
Set-Culture
call:Caveat re interactive (command-line) use:
[cultureinfo]::CurrentCulture = 'de-DE'; Get-Date
works as expected, because it is part of the same command line, but when executing justGet-Date
as the next command, the current culture has reverted to the one that was current at session-startup time.This perhaps surprising asymmetry -
Set-Culture
only applying to future sessions, butGet-Culture
reporting the current session's (startup) culture - is something that may change in future PowerShell Core versions.