Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Last active August 26, 2021 11:54
Show Gist options
  • 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
@Maddog1314
Copy link

Thanks for posting this Talking Moose! Would I import this as a script and then run it on a policy to all Macs?

@talkingmoose
Copy link
Author

It's meant to be used as an Extension Attribute (EA) in Jamf Pro. Add it to Settings > Computer Management > Extension Attributes and then it will collect lists of 32-bit apps at every inventory update. Look for the name you give the EA in each computer record, Advanced Computer Searches or Smart Computer Groups.

@Maddog1314
Copy link

Thanks for getting back to me so soon! I put your script into an Extension Attribute and made a Smart Group from it. When I look at inventory I see most blank but some list the applications I've included in the attached document. The Smart Group indicates that there are no Macs with 32bit applications installed and the criteria for that group is also on the attached document. This is a contradiction and something is probably wrong with my Smart Group criteria. Does anything look incorrect to you? Thanks!

32bitimage

@talkingmoose
Copy link
Author

talkingmoose commented Sep 26, 2019

Instead of using "yes" or "true" for your Smart Group's value, use "is not <blank>", putting nothing in for <blank>.

@iRyan757
Copy link

I just ran this in my environment. It does pull in a list of apps but it is also looking at folders on my desktop. Is there a way to limit the app search to just /Applications/?

@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