I have been struggling to remove all older version of Java JDK/JRE from bulk machines, i tried using uninstall string from Registry manually in a batch file. but that didn’t fix all the issues.
I came up with this idea to kill many birds with one shot. In this powershell script i am asking for java and specifying the version should be less than like “1.8.0_2120.10”.
Make sure you set your current latest java version to keep it other it will remove all java JDK-JRE both.
1- Get list of all java version installed
######################################################################### ################ List All Java Versions intalled ########################### $java = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match “java” } $java | select name, version | ft
2- Remove the Java version, change ur current version “8.0.2120.10”
$java = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match “java” -and $_.version -lt "8.0.2120.10" } $java.Uninstall()