I'm having kind of a strange problem. When the server's Region and Language
settings is set to English (United States)
there are no issues with objects containing the date and time. But when I change it to my countries local Dutch (Belgium)
I am experiencing problems in some of my PowerShell scripts.
Is there somewhere a variable in PowerShell that needs to be set to fix this? Or do I have to default to English date formats on the server all the time?
We use for example the SQL module
provided by Don Jones for filling up an SQL database. This line generates an error when it's set to Dutch, but not when it's set to English:
if ($properties[$property] -eq 'datetime2') { [datetime]$prop = $result.GetDateTime($result.GetOrdinal($property)) }
The only thing I do to retrieve the date is Get-Date without anything special. And it generates this error when set to Dutch (Belgium)
:
Exception calling "ExecuteNonQuery" with "0" argument(s): "Conversion failed when converting date and/or time from char
acter string."
I've experienced the same problem when generating stuff for Excel sheets. It also complains about the date time format.