Clean up attachments

8 months ago   •   2 min read

By macstuff
Table of contents

A couple of months ago one of my lovely customers was fiddling around with the API. The idea was to upload data provided by the user or something like logs directly to Jamf Pro.

The files uploaded manually or via the API will be available for someone with access to Jamf (Like someone from the Service Desk, Support, Admins). They can delete/download files this way. See below for a reference screenshot.

Attachments in Jamf Pro 10.32.0

Now, what if you were having a lovely time testing out this API feature on your test device on Friday. You set this up to run on a recurring check-in since you were actively working on it and wanted the upload to keep uploading stuff. You keep the device active and go home. After a great weekend you are eager to test out your scripts again, but, you come back to work with 10 thousand attachments!

Jamf Pro does not give you the ability to delete all these in bulk at the moment of writing. To fix this, I created the script below to fix that.

Keep in mind that this script only runs for one device, and only removes it up to 450 attachments. If enough people actually want to use this script for other reasons I can modify it but for now, I'll share the one that was used!

Check out this script on Github! Github doesn't allow embedding so I used an external tool for this. The script above may be old, always check out my repositories!

API/ at main · macstuffdev/API
All scripts that do something with the API. Contribute to macstuffdev/API development by creating an account on GitHub.

Something you want to see? Something you want to know? Email me at [email protected] and I’ll consider it!

Feedback about my site or content? Contact me at [email protected]

Spread the word