I understand what you're saying but that is not the issue here.
When using get-date -format or .tostring() it should return a string in the format specified. Which until now worked perfectly for me, but just not with this specific format. The issue is just with the yyyy-MM-ddTHH:mm:ss
format.
In my previous post I printed the date and what type of property it is, which was a string, and yet it printed the friendly datetime format. But when placed in an object or string it works fine, as shown with the code you shared.
A test run:
(Also, I noticed there is also an issue where VSCode also transforms the output of a job with this specific datetime format. The output from the job are not the same in VSCode and in the azure portal. But for that I made a issue on the github page of the VSCode extension)

The code for the run:
$data = @{
"StartDate" = "$(Get-Date -Format "yyyy-MM-ddT00:00:00")";
"EndDate" = "$(Get-Date -Format "dd-MM-yyyyT00:00:00")";
} | ConvertTo-Json
$data # as json string
$data = $data | ConvertFrom-Json
$data
"Startdate: " + $data.StartDate.GetType().FullName
"Endate: " + $data.EndDate.GetType().FullName
So a thing to note here. PowerShell for some reason automatically transforms the startdate string to a datetime format, which is weird and I think should not happen?I have two strings in the hashtable, the hashtable is to simulate a parameter for the script as json string. We can see that both are correct strings when the $data variable is printed with it being a json string, so we know the string is the correct formatted string.
Next I convert it from JSON as I need specific properties at specific places.
With another print it can be seen that the startdate is now printed in the friendly way, even more unexpected is when we look at the type it is now a datetime object instead of a string? But the other string is not converted to a datetime object.
So in my eyes this is unexpected behavior. PowerShell receives a string then it should stay a string until it is explicitly changed or cast or something which I do manually. It should not be that PowerShell starts changing values without me expecting it.