Java J2RE - Configuration Baseline Script

MartinH18

Bit poster
As i couldn't seem to find a way to query Java version in SCCM via "installed applications" created a script to check compliance for latest version of Java 1.8.0_171 (latest at time of writing, easy to edit script to detect version required)
create a configuration item, use script below as discovery script, set compliance rule "equals OK". Deploy baseline.
**Note** this script detects Java J2RE, not the JDK.

#!/bin/bash
JAVA_VERSION="$(echo "$(/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version 2>&1)" | grep "java version" | awk '{ print substr($3, 2, length($3)-2); }')"
if [ $JAVA_VERSION = "1.8.0_171" ]
then
echo "OK"
else
echo "Fail"
fi

Hope its useful to someone.
 
Back
Top