How to set culture in PowerShell?
I think this will work:
$currentThread = [System.Threading.Thread]::CurrentThread
$culture = [System.Globalization.CultureInfo]::InvariantCulture
$currentThread.CurrentCulture = $culture
$currentThread.CurrentUICulture = $culture
This idea came from:
Link
This is the function I use for testing string/formats in other cultures:
function Using-Culture (
[System.Globalization.CultureInfo]
$culture = (throw "USAGE: Using-Culture -Culture culture -Script {...}"),
[ScriptBlock]
$script = (throw "USAGE: Using-Culture -Culture culture -Script {...}"))
{
$OldCulture = [Threading.Thread]::CurrentThread.CurrentCulture
$OldUICulture = [Threading.Thread]::CurrentThread.CurrentUICulture
try {
[Threading.Thread]::CurrentThread.CurrentCulture = $culture
[Threading.Thread]::CurrentThread.CurrentUICulture = $culture
Invoke-Command $script
}
finally {
[Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture
[Threading.Thread]::CurrentThread.CurrentUICulture = $OldUICulture
}
}