Hi Antoine
You already received the JSON answer from Invoke-RestMethod. This means that the request has been successfully sent to the AE REST service and the service returned an errorneous http code and a JSON response:
{ "code" : 45107, "error" : "Cannot logon to Automation Engine.", "details" : "The credentials
(user/dept/pwd) are not valid." }
The errorneous http code causes the invoke-restmethod to throw an error, that's why everything turns red :-).
Did you replace the "user/dept:pwd" string according your username/department/password?
Regards
Joel