Fix 'The underlying connection was closed' error in Invoke-RestMethod from PowerShell

When calling a url from PowerShell like this …

1
Invoke-RestMethod -Uri https://dashboarddelivery.nextens.nl/api/invalidate/

… fails with …

1
Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.

… you should add this line to your script:

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

(because PowerShell by default uses TLS 1.0 for web requests).