Check if java is installed and running

Since the beginning of time we see java being installed by default. With the changing license structure of Oracle and the monthly increase in java vulnerabilities it is time to reduce the java footprint to the bare minimum.

this worklet does a simple check if Oracle Java or Amazon Corretto is installed and if so checks if there is a running JAVA process to help determine if JAVA is needed on that system or if it can be removed.

Evaluation Code

EXIT 1

Remediation Code

$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match "Java" -or $_.DisplayName -match "Corretto" })
$version = "(Vendor: " + $installed.Publisher + " " + "Version: " + $installed.DisplayName + ")"

If(-Not $installed) {
    Write-Output "Java is not installed"
	EXIT 0
} else {
    IF (Get-Process -Name "java" -ErrorAction SilentlyContinue) {
	Write-Output "$version is installed and currently running."
    }
    else {
    Write-Output "$version installed but not being used at the moment."
    }
}
```

Version management is handled on our github page;
https://github.com/Dutch-Technology-eXperts/Automox/blob/main/check_java.ps1
1 Like

What a great idea!