This also converts the date in PowerShell 7.x, rather than passing the original UTC date string ( e.g. ‘2020-01-03:10:20:20+11.00’), as Windows PowerShell does. So, I’m hoping they also add date conversion suppression to Invoke-RestMethod also.
Actually, IMO they should leave the default behavior alone and add a parameter to these cmdlets to do the date conversion, if that’s what you need.
For now, I’m converting the date object back to the original string, using:
That’s interesting. In my testing, I connected to a service that sent dates in the response and the response was always the original timestamp in the raw data, it was only when processed by ConvertFrom-Json that the format changed.
Pretty sure that Invoke-RestMethod uses ConvertFrom-Json to automatically parse responses to a PSObject. If you wanted to avoid the parsing, you would have to use Invoke-WebRequest to get straight JSON returned. Not sure why they would do automatic date conversion to local time, that is just silly, just convert the date and let the user do conversions if they wanted.