If you encounter a code that throws an error saying unable to establish tls session with the target server, most likely tls version is lesser than version 1.2 and your server only accepts 1.2
#To ensure the powershell use tls version 1.2. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12