Message Tracking Using Exchange 2010 Shell Only Works With US Date Format
If you use a date format other than US (mm/dd/yyyy), the message tracking cmdlet (Get-MessageTrackingLog) in Exchange 2010 fails. Let’s walk through an example to prove this with Exchange 2010 SP2 UR3 at the backend. I have sent an email to my wife today (14th Oct) at 20:41. A simple Get-MessageTrackingLog command with the sender…
If you use a date format other than US (mm/dd/yyyy), the message tracking cmdlet (Get-MessageTrackingLog) in Exchange 2010 fails.
Let’s walk through an example to prove this with Exchange 2010 SP2 UR3 at the backend. I have sent an email to my wife today (14th Oct) at 20:41.
A simple Get-MessageTrackingLog command with the sender and recipients parameter brings the desired output.
When the cmdlet is extended by specifying a time frame (dd/mm/yyyy), it returns the following error message.
Cannot process argument transformation on parameter ‘Start’. Cannot convert value "14/10/2012 20:38" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
If I run the same command with 14th Oct in US format (10/14/2012), Exchange displays the message trace.
In short, unless you use the mm/dd/yyyy format for date with the Get-MessageTracingLog cmdlet, you are not going much further with the trace ;)
Is this a bug? Has anyone come across this before? Any workarounds?
I explained the official workaround on linked-in (use [datetime]::Parse( ) ).
That being said, to be clear, MS is not insisting on a “US date format” but what they call a “culture invariant” date format. It just so happens that this is the en-US date format. :) A picky difference, to be sure, but relevant.
There are a number of cmdlets, not just in Exchange, where this occurs. It isn’t a bug, it is “works as designed and intended”. Arguably, the documentation could be improved.
Michael B. Smith
Consultant and Exchange MVP
Thanks for the explanation Michael.
its mentioned in the help info for get-messagetrackinglog cmdlet. that the -start vaule should be in specific format.
any way nice to learn this.
Thanks Sahal. But, there should be a reason why MS insists on US date format!
Yep, seems to be the way it is.
I wrote an article with some examples of searching time/date ranges in message tracking logs:
I don’t run into that little quirk too often because normally I use Get-Date to specify relative time/date rather than fixed ones.
But one way to get around any awkwardness with the US time format is to use Get-Date to set a variable with the start/end time + date that you want, then use the variable in the Get-MessageTrackingLog command.
[PS] C:\>$date = Get-Date “17/9/2012 12:00:00”
[PS] C:\>Get-MessageTrackingLog -Start $date -End $date.AddHours(8) -ResultSize unlimited
Thanks for the tip Paul.
Yes, I have come across it lots of times as in Australia the date format is dd/mm/yyyy.
Since it doesn’t affect functionality, I wouldn’t consider it a bug. Instead it appears to be an unfinished localization issue, considered by MS not sufficiently important to complete.
Never took the effort to look up possible references. I just accepted the fact and used it with US dates.
Given that MS releases language packs and Exchange 2010 install itself in a number of languages, this should be fixed. I know it is a minor issue, but people do use Shell for advanced query.
This is just a guess. could that be because of the date setting of the OS? (MM/DD/YYYY)
Im here in the states so….
No Percy, date settings on the server are correct, set to UK timezone. Looks like it is a bug!