#powershell Non US Locale Culture (Thread)

Windows PowerShellIn an environment where US English is not the language locale selected during installation of the Windows OS or as defined in Control Panel*, operations in PowerShell may behave differently or fail altogether (where dependencies on this setting may not be obvious e.g. COM object interaction with Microsoft Office Suite of products).

To avoid nasty surprises in PowerShell, consider saving both the current culture and UI culture values for the present (current) thread, set them explicitly to “en-us”, perform the needed tasks then revert back to the original system values.

The static threads we are looking for are:

[System.Threading.Thread]::CurrentThread.CurrentCulture
[System.Threading.Thread]::CurrentThread.CurrentUICulture

* Region and Language > Formats > Format / Location > Current Location

Bookmark the permalink.

Leave a Reply