Powershell script to update Java to latest version

korymiller picture korymiller · Oct 28, 2014 · Viewed 9.6k times · Source

We have an application that is Java dependent that we are working on a SCCM installer to push out to clients.

Due to Java being updated almost monthly (and the old updates expiring 30 days thereafter) we're looking for a way to have the SCCM installer stay updated with the latest Java version. We have the ability to run a Powershell script from our SCCM installer, but we haven't found a way to write a script that will automatically download and install the latest Java version.

Does anyone know if this is possible, and how we could go about it?

Thanks in advance!!

Answer

Alex H picture Alex H · Oct 28, 2014

Please have a look at this for downloading a file with powershell and this for installing java silent. For example:

Invoke-WebRequest $address -OutFile $destination
# $addressis the http-address of the installer
# $destination is a Path where the the downloadoutput should saved to
$destination /s
# with the '/s' Parameter you are starting the installer silent

If you can get the download link, you should be able to download and install java. But atm i have no idea how you can get the link. I hope this helps a little bit.