File downloaded with WebClient or Invoke-WebRequest are corrupted


Downloading a file with WebClient like this:

$  WebClient = New-Object System.Net.WebClient $  WebClient.DownloadFile("https://xxxxxx.com/xxxxx/xxx.exe","C:\Users\user\Desktop\xxx.exe") 

results in “The file or directory is corrupted and unreadable”

Same goes for Invoke-WebRequest:

$  url = "https://xxxxxx.com/xxxxx/xxx.exe" $  output = "C:\Users\user\Desktop\xxx.exe" Invoke-WebRequest -Uri $  url -OutFile $  output 

What do you think is wrong?