Skip to content

Instantly share code, notes, and snippets.

@macmule
Created November 28, 2021 18:14
Show Gist options
  • Save macmule/d6f49a5eeae90792a9d7f1422bcec3e0 to your computer and use it in GitHub Desktop.
Save macmule/d6f49a5eeae90792a9d7f1422bcec3e0 to your computer and use it in GitHub Desktop.
#!/bin/bash
####################################################################################################
#
# License: https://macmule.com/license/
#
####################################################################################################
# List all Applications in /Applications
applicationsList="$(ls -d /Applications/*.app)"
# For each app in Applications...
for app in $applicationsList;
do
# Check to see if the .app bundle has a receipt
if [ -f "$app"/Contents/_MASReceipt/receipt ];
then
# Return App Store Certificate expiration
firstCertExpiry=$(openssl pkcs7 -inform der -in "$app"/Contents/_MASReceipt/receipt -print_certs -text | awk -F ' : ' '/Not After :/ { print $2; exit }')
# Add the above to an array
appArray+=("$app" : "$firstCertExpiry" "\n")
fi
done
# Echo out for Extension Attribute
echo -e "<result>${appArray[*]}</result>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment