-
-
Save talkingmoose/cd142f08c95613e5bff483fa55611b8b to your computer and use it in GitHub Desktop.
#!/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 |
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!
Instead of using "yes" or "true" for your Smart Group's value, use "is not <blank>
", putting nothing in for <blank>
.
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/?
@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.
leaving the the Smart Groups value at nothing worked for me. Thanks for all the help!
Thanks
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 ?
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.