Why does PowerShell ignore the system date and time format?
I live in the UK where we use the dd/mm/yyyy date format and although my Exchange server's OS is set to use UK date format my PowerShell commands insist on using the US format - mm/dd/yyyy.

For example, if I run the following command:

Get-MessageTrackingLog -Start "30/04/2015"


I get the error:
Cannot process argument transformation on parameter 'Start'. Cannot convert value "30/04/2015" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."

If I reformat the date thus
it works fine:
Get-MessageTrackingLog -Start "04/30/2015"

It seems that PowerShell is ignoring the system date and time format.
Anyone got a fix for this?


  • Edited by AndyChips 17 hours 48 minutes ago
May 12th, 2015 9:41am

We aren't in a position to answer most "why" questions, sorry.
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2015 10:40pm

Hi,

The Start parameter use the short date format defined in the Regional Options settings for the computer on which the command is run.

Regional Options settings can be found in Control panel -> Clock, Language, and Region -> Region.

Then check the short date format.

Refer from:

https://technet.microsoft.com/en-us/library/aa997573%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396

Best Regards.

May 12th, 2015 11:00pm

Thanks Lynn-Li, but the short date is already correctly set, as I indicated in my original post.
Free Windows Admin Tool Kit Click here and download it now
May 13th, 2015 2:17am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics