'using exchange powershell - cannot determine the content type of the HTTP response

I have a C# console app that I wrote that is trying to enable mail for an AD user.

using (Runspace EnableMailboxRunspace = RunspaceFactory.CreateRunspace(ConnectionInfo(ExchangeServerURI, ExchangeUser, ExchangePassword)))
{
  EnableMailboxRunspace.Open();

  // Create a pipeline to process the commands
  using (Pipeline EnableMailboxPipeline = EnableMailboxRunspace.CreatePipeline())

This works just fine in the dev environment, but I cannot get it to run on any production server. When the CreatePipeline command is executed I get this error:

"Connecting to remote server pc799.csnt.princegeorge.ca failed with the following error message : The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid. For more information, see the about_Remote_Troubleshooting Help topic."

I have tried this running as multiple different users, including domain admins. This app did work a few months ago, but now it doesn't work. We moved from a fully on prem system, to a hybrid M365/On prem system and something in that seems to have broke it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source