We have used System.Net.WebRequest for managing FTP files by powershell script. But, we are frequently getting "The underlying connection was closed: An unexpected error occurred on a receive." whenever script try to connect with Sharepoint online by


. Any idea?

We have used below link to fix it but nothing happened..

https://blog.mamc-llc.com/2020/07/08/the-underlying-connection-was-closed-an-unexpected-error-occurred-on-a-receive-when-running-wget-curl-or-invoke-webrequest-on-windows-in-powershell/ https://sharepains.com/2016/04/22/connect-pnponline-common-error-messages/ https://github.com/pnp/PnP-PowerShell/issues/1566

1 Answer 1


You may try to update your default security protocol to be TLS 1.2+ to test if it solves your issue.

enter image description here Reference:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.