Script to Check if Software and version has been installed etc..

sara_mccullar
New Contributor III

I am trying to find/write a script to check that software like Office is installed and the latest version. I am also trying get a script that can check the jamf record of the computer to make sure the name has been changed and the asset tag has been added.

I need the script for my it staff to run after setup to make sure they got these configurations correct. I need it to come back and tell them that software is or isn't installed and if the name change has or hasn't happened along with adding the asset tag. Now I do have policies they are suppose to use to rename and add the asset tag.

6 REPLIES 6

mbracco
Contributor

Hy, make a check if Application x.app folder is located in /Applications, then a defaults read /Applications/x.app/..../Info.plist CFBundle...... to see if it's the desired version. Simply bash..

I need to have it say that certain software is installed but version not correct or that software and version are correct or software missing. 

YanW
Contributor III

You can use Inventory Display to show Asset Tag and username. You can add each Office app in Patch Management to track the version. You can use Smart group to check who doesn't have the app installed. 

sara_mccullar
New Contributor III

Yes I know but what I need is a policy in self service for my techs to run after they believe they have completed setup to make sure that computer is truly finished being setup.

sara_mccullar
New Contributor III

so this script gives me the read out that i want.

#!/bin/bash
app_path="/Applications/Microsoft Excel.app"
desired_version="16.55"

#Get the line, regardless of whether it is correct
version_line=$(plutil -p "${app_path}/Contents/Info.plist" | grep "CFBundleShortVersionString")
if [[ $? -ne 0 ]]; then
version_line=$(plutil -p "${app_path}/Contents/Info.plist" | grep "CFBundleVersion")
if [[ $? -ne 0 ]]; then #if it failed again, the app is not installed at that path
echo "$app_path not installed at all"
exit 123456
fi
fi
#Some text editing to get the real version number
real_version=$(echo $version_line | grep -o '"[[:digit:].]*"' | sed 's/"//g')
if [ "$real_version" = "$desired_version" ]; then
echo "$app_path $desired_version is installed"
exit 0
fi
echo "${app_path}'s version is $real_version, not $desired_version"
exit 1

 

what i also want a pop up telling me that  excel is 16.55, excel is not installed, or excel is not 16.55.  I've been looking to see if adding osascript display notifcation or something like that would work. I just don't know how to get it to display the output from the script

mbracco
Contributor

We use depnotify in our scripts, jamfhelper for fallback and osascript if jamfhelper not present. And a logfile to be able to trace back what's done.