PowerShell Script using Webclient to download files from URL with basic authentication

The below PowerShell script will use WebClient to download files from a URL that is requesting basic authentication. #!powershell # Setup Key Values ################################### $URL="http://yourserver//filetodownload.exe" $DOWNLOADTARGETPATH= "C:\filetodownload.exe" $USER_TO_ACCESS_DOWNLOAD = "YourUserName" $USER_PW = "YourUserPassword" # Force TLS 1.2 ################################### [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Download the file with authentication using webclient [...]