Code is this:
$test = '01/10/2017'
Write-Host $test #Shows 01/10/2017
$test = $test.Date.ToLongDateString()
Write-Host $test #Shows 10 January 2017 instead of 1 October 2017
Get-Culture shows en-GB (correct) but Get-UICulture shows en-US
On Windows the Locale is set to en-GB so how to I tell Powershell ISE to switch to this?
What version of windows and PowerShell are you running? I used to have this issue - and you can’t change the UICulture - but on my Windows 10 machine with PowerShell 5.1 both cmdlets show en-GB as they should
I have Windows 7 Pro and Powershell 5. This problem is really causing chaos as all dates in Windows are dd/MM/yyyy so, for example, when I retrieve an environment variable (in PS) set to ‘13/10/20’ I get “String was not recognized as a valid DateTim”.
Is there maybe a Registry entry I can change?
From a quick google i found the following. The short version is that you change UICulture with the Language control panel, and Culture with the Region control panel. Culture just affects things like date / time / currency / number formats; UICulture is the actual language pack.
I agree; the problem being that everything is set to UK english in both of those places. I have done a temporary fix by adding a function to ‘split’ the date (reversing the Month/Day ones) before calling ToLongDateString() which works.