PowerShell – Working with URLs
This command is used to get the content from a web page by sending the HTTP or HTTPS requests to that page. In other words, you can simple parse or scrape a web page for images, links, etc.
In response, you will see a parsed result including status code, links, images, input fields, etc.
By default, PowerShell uses TLS 1.0 for HTTP / HTTPS requests.
You can easily check the TLS version of any website.
Google Chrome – Click F12 > Go to Security Tab
Mozilla Firefox – Click on the padlock icon on the left of address bar and then click on the right arrow as shown below.
Click on more information and you will see a popup with TLS version.
Internet Explorer – Open a website > Right click on page > Click on Properties
Not all the websites use TLS 1.0 and it is not possible to establish a secure connection to a website using different TLS version.
So in order to make HTTP or HTTPS calls using Invoke-WebRequest, you have to force PowerShell to use a different version (eg. TLS 1.2)
# Forcing PowerShell to use TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
If you are wondering, which versions you can use with PowerShell, then simply use the following cmdlet