EvotecIT/PSWinDocumentation.O365HealthService

An unexpected error occurred on a send

Closed this issue · 8 comments

I use O365HealthService for two weeks and it worked correctly, but yesterday started to have error executing the module.
Any idea what it might be?

Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
At C:\Program Files\WindowsPowerShell\Modules\PSWinDocumentation.O365HealthService\0.2.2\PSWinDocumentation.O365HealthService.psm1:307 char:18

  • ... Services = (Invoke-RestMethod -Uri "https://manage.office.com/api/v1. ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
      API

I've moved this to a proper repository. Just tested on 7.0, 5.1, and 6.2.3 and it seems to work fine here.

But to be honest I've got a similar report few days ago over the email

image

Which looks exactly like yours.

Maybe this:

https://blogs.msdn.microsoft.com/webdav_101/2019/02/28/invoke-restmethod-the-underlying-connection-was-closed-an-unexpected-error-occurred-on-a-send-while-using-powershell/

If you have gotten the "Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send." error while using PowerShell then add the line below to your script.

​[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

PowerShell calls uses TLS 1.0 for web requests by default. However, Exchange is expecting a higher level of TLS, so you need to tell PowerShell to use 1.2 instead of the default of TLS 1.0.

Below are links for additional information:

Have you enforced TLS 1.2 recently? Can you verify this?

Perfect !!!
I Add

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

and now it's ok !

Ok, I'll add it to the code and publish a new version. Sorry for the inconvenience.

There was no inconvenience ;). I appreciate your excellent work in making this module.

Please test the new version. Update-Module ... and then restart PS and let me know. Thank you!