Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Last active August 26, 2021 11:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talkingmoose/cd142f08c95613e5bff483fa55611b8b to your computer and use it in GitHub Desktop.
Save talkingmoose/cd142f08c95613e5bff483fa55611b8b to your computer and use it in GitHub Desktop.
In preparation for macOS 10.15, this list identifies 32-bit apps in the Applications folder and returns the list to an extension attribute in Jamf Pro. The returned list may include Xcode because it contains an app with a non-standard file in place of a binary deep within its app bundle. This may be ignored.
#!/bin/bash
# create a list of paths in the Applications folder for testing
MacOSPaths=$( /usr/bin/mdfind kMDItemKind==Application )
# recurse through the list and create a list of apps with 32-bit binaries
while IFS= read aPath
do
cd "$aPath/Contents/MacOS"
testBinary=$( /usr/bin/file * | /usr/bin/grep '64-bit' )
if [ "$testBinary" = "" ]; then
foundApp=$( /usr/bin/sed 's/\.app.*$/\.app/g' <<< "$aPath" | /usr/bin/grep ".app" | /usr/bin/awk -F "/" '{ print $NF }' )
# to show full paths, comment line 14 and uncomment line 17
# foundApp="$aPath"
foundApps=$( echo -e "$foundApps\n$foundApp" )
fi
done <<< "$MacOSPaths"
# sort the list and app names to Jamf Pro
appList=$( /usr/bin/sed '/^$/d' <<< "$foundApps" | /usr/bin/sort --unique )
echo "<result>$appList</result>"
exit 0
@talkingmoose
Copy link
Author

@iRyan757, on line 4, you could replace the command between the parentheses with this:

/usr/bin/find /Applications -name "*.app" -maxdepth 2 -print

This should find apps in the Applications folder and one sub-folder deep like Utilities.

@Maddog1314
Copy link

leaving the the Smart Groups value at nothing worked for me. Thanks for all the help!

@iRyan757
Copy link

Thanks

@mani2care
Copy link

how can I fetch from extension attribute for all the machine and also I want all the application running from the machine even stored the application in a different place also in different places

any option ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment