Powershell - Script Java JRE Upgrade

I currently run the Java JRE on my 2000+ workstations.  Unfortunately, I don't have a good enterprise deployment method for Java.  Historically, I have relied on the version that would have been installed upon image deployment to last the OS through its lifetime in the enterprise.  Once the machine needs to be reimaged, a new version of Java will be installed as part of the imaging process.  This has worked well, until now.  I have now been informed that the version of my JRE on the majority of my machines is too old to support a business application that is widely used.  I'm now faced with the question of how to update many older versions of Java to something more recent.

I'm thinking that a Powershell script might be the way to go, as this is my language of choice.  Would it be possible to pull a value from the registry into a variable that would then allow me to uninstall an old version?  I have many different updates of Java 7 installed in my enterprise, so not all machines will have the same versioning.  I then need to script an unattended install of Java 7.65 (or newest version) to upgrade the machines.  In my experience, the Java installer does not replace old versions, it only installs two versions side-by-side.

What would be the best way to conquer this task?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I would say an easy route would be querying the registry for the version value you need.

If the version is less than the current expected version then copy and run the msi that you would use to install the latest version.

If you can give me an example of the output from a computer where you query for the version installed. maybe I can give more details.
In my experience, an installation of Java will upgrade an existing installation if:
- the major version number is the same (i.e. 1.7_65 will upgrade 1.7_17)
- and if the previous install is in the default path.  I can't remember the terms that Oracle uses to describe this, but there are two types of install: one using the generic/default path (like "C:\Program Files (x86)\Java\jre7"), and another using a version-specific path (usually meant for installing multiple versions or when an app is dependent on a specific version being installed).

You may test out deploying via Group Policy Software Deployment.  To do so you will have to extract the .MSI.
You can then push out updates in the same way.  May not help you with cleaning up old versions, but would probably be a good path moving forward.  I've played around with this before, and it seems to fit your scenario.  Perhaps pushing out the latest, and then running the Java Uninstall Tool (but that would require user intervention).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.