Question:
I am trying to download the java jdk using powershell scripting as given in the link below
. Here as the author has specified , if I Change the source url where the latest jdk is present
i.e.,
http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-windows-x64.exe
the content is not getting loaded , only about 6KB gets downloaded . I have a doubt , whether the download limit in powershell script is only 6KB?
Here is the code :
1 2 3 4 5 |
$source = "http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-windows-i586.exe" $destination = "C:\Download\Java\jdk-7u60-windows-i586.exe" $client = new-object System.Net.WebClient $client.DownloadFile($source, $destination) |
Answer:
On inspecting the session on oracle site the following cookie catches attention: oraclelicense=accept-securebackup-cookie
. With that in mind you can run the following code:
1 2 3 4 5 6 7 |
$source = "http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-windows-i586.exe" $destination = "C:\Download\Java\jdk-7u60-windows-i586.exe" $client = new-object System.Net.WebClient $cookie = "oraclelicense=accept-securebackup-cookie" $client.Headers.Add([System.Net.HttpRequestHeader]::Cookie, $cookie) $client.downloadFile($source, $destination) |