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. ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
Maybe this:
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:
- An Update on Office 365 Requiring TLS 1.2
https://blogs.technet.microsoft.com/exchange/2018/02/09/an-update-on-office-365-requiring-tls-1-2/ - Preparing to use TLS 1.2 in Office 365
https://support.microsoft.com/en-us/help/4057306/preparing-for-tls-1-2-in-office-365
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!