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
########################################################
write-host ” ” -ForegroundColor Yellow
write-host “Start Downloading files from: $URL” -ForegroundColor Yellow
write-host ” ” -ForegroundColor Yellow

$creds = new-object System.Net.NetworkCredential($USER_TO_ACCESS_DOWNLOAD,$USER_PW)
$webclient = new-object System.Net.WebClient
$webclient.Credentials = $creds
$resutl = $WebClient.DownloadFile( $URL, $DOWNLOADTARGETPATH