What facilitates package removal in Jamf Pro?

cghigliotty
New Contributor

Hey all,

I've used JAMF's built in uninstall option (indexing package in Casper Admin <> selecting Allow package to be uninstalled) but does anyone know how JAMF actually facilitates the uninstall? Is it just looking at the BOM in /private/var/db/receipts and removing the listed items?

Thanks!

1 REPLY 1

Stevie
Contributor

Hello,

I use a script with each and every install to clean up old receipts. I also use smart groups for application versions so if a user upgrades to the latest version outside of JamfPro this script is run once to clean up any cached packages and old receipts.

I set parameter 4 as "ReceiptName" and parameter 5 as "PackageName"

I sure a few people online can improve on this script.

Steve

#!/bin/bash

if [ "$4" != "" ]; then
    ReceiptName="$4"
else
    echo "Receipts paramater 4 was empty. This needs to contain the full receipt name. Exiting..."
    #ReceiptName="com.google*"
    exit 1
fi

if [ "$5" != "" ]; then
    PackageName="$5"
else
    echo "Receipts paramater 4 was empty. This needs to contain the full receipt name. Exiting..."
    #PackageName="GoogleChrome"
    exit 1
fi

# Remove System Receipts
echo "Removing Receipts"
receipts=$(pkgutil --pkgs=$ReceiptName)

for areceipt in $receipts
do
    pkgutil --forget $areceipt
done

# Remove Jamf Receipts

echo "Removing Casper Packages"
IFS=$'
'

receipts=`mdfind -onlyin /Library/Application Support/JAMF/Receipts/ "kMDItemContentType == 'com.apple.installer-package-archive'" | grep "$PackageName"`
echo $receipts
for areceipt in $receipts
do
echo $areceipt
    rm -Rfd $areceipt
done