"Exception calling "DownloadFile" with "2" argument(s): "An exception occurred during a WebClient request."

If you look at the MSDN documentation for the DownloadFile method, you'll notice that the second parameter is a filename, not a directory. So, if you re-define $destination to something like:

$destination = "c:\CHPACS\java-installer.zip"

then it should work.

Check secondly that the file that you're trying to download isn't open or being executed at the moment. This exception will be raised if the file is in use.


You should give a file name as David said + the folder should exists.

Tags:

Powershell