N-central Troubleshooting
The need of changing security protocol before executing invoke-webrequest in Powershell scripts
Last Modified
Fri Feb 14 20:05 GMT 2020
Description
- This article helps to understand the need of changing security protocol before executing "Invoke-WebRequest" in Powershell scripts.
- This is applicable when the Automation Manager or Scheduled Task is being used to run the Powershell scripts.
Environment
- N-able N-central
- Automation Manager
- Microsoft Windows Operating Systems
Solution
- Websites can be configured to accept requests that are using only certain protocols, for example TLS1.2, although the protocol being used by Powershell could be different.
- Therefore in some cases, when the Powershell command line "Invoke-WebRequest" is being executed, it could fail due to the protocol mismatch.
- When this happens, the command line of changing the security protocol has to be executed before the "Invoke-WebRequest" can execute successfully.
- A sample command line to change the security protocol to be TLS1.2 is listed below:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
- Example command to test SIS connectivity:
Invoke-WebRequest -Uri 'http://sis.n-able.com/ComponentData/RMM/1/PMESetup_details.xml'