Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
talkingmoose / Set Computer PreStage Scope.bash
Last active February 4, 2025 02:05
As of Jamf Pro 10.14, the Jamf Pro API (/uapi) allows access to create and update scopes for computer PreStage Enrollments. Edit the information at the top and include a list of computer serial numbers for the COMPLETE scope. (The script replaces the scope list; it doesn't update.) Be sure to leave the opening and closing parentheses.
#!/bin/bash
# server connection information
URL="https://talkingmoose.jamfcloud.com"
username="API-Editor"
password="P@55w0rd"
# provide the Jamf Pro ID of the PreStage Enrollment; look in the URL when viewing the PreStage Enrollment
prestageID="1"
@talkingmoose
talkingmoose / Kill Running Apps.bash
Created June 27, 2019 16:07
Useful for killing all running applications that may prevent a restart for an upgrade. Killing apps does not allow for saving work. Use only as a last resort.
#!/bin/bash
# there's probably a better way to use lsappinfo to get the list of apps, but it's not well documented
appsList=$( /usr/bin/lsappinfo list | /usr/bin/grep -B 4 Foreground | /usr/bin/awk -F '\\) "|" ASN' 'NF > 1 { print $2 }' )
# kill each app by name except Finder
while IFS= read anApp
do
if [ "$anApp" != "Finder" ]; then
/usr/bin/pkill "$anApp"
@talkingmoose
talkingmoose / MacBook Battery Recall Lookup.bash
Last active June 22, 2019 00:21
Look up Jamf Pro serial numbers that may be eligible for Apple's 15-inch MacBook Pro Battery Recall Program. This logs results to a file in the same location as the script. https://support.apple.com/15-inch-macbook-pro-battery-recall
#!/bin/bash
# Based on the script by @nicktong found at https://www.jamf.com/jamf-nation/discussions/32400/battery-recall-for-15-mid-2015-mbp
## Jamf Pro URL and credentials
URL="https://talkingmoose.jamfcloud.com"
username="api-auditor"
password="P@55w0rd"
@talkingmoose
talkingmoose / Enable all macOS software updates.bash
Last active December 16, 2025 07:48
The /Library/Preferences/com.apple.SoftwareUpdate.plist seems impervious to being managed via configuration profile (at least on macOS Mojave). While not enforced management, add this script to a Jamf policy and run it on a routine basis such as once per week on scoped Macs.
#!/bin/bash
/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool TRUE
/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload -bool TRUE
/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticallyInstallMacOSUpdates -bool TRUE
/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall -bool TRUE
/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall -bool TRUE
/usr/bin/defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdate -bool TRUE
exit 0
@talkingmoose
talkingmoose / Create one-to-one iOS device and Apple TV assignments.bash
Last active June 8, 2019 21:20
Creates Moble Device Configuration Profiles in Jamf Pro to pair one iOS device with the Apple TV Remote app to one Apple TV. Useful for hospital or school environments to simplify the device list when browsing and increase security by enforcing which devices can communicate.
#!/bin/bash
<<ABOUT_THIS_SCRIPT
-----------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/talkingmoose/520c79d8d0f9bc49c9e07ca43122225c
@talkingmoose
talkingmoose / Change Mobile Device Username.bash
Created June 4, 2019 05:04
Updates username filed with supplied new username in list of devices by serial number.
#!/bin/bash
# server connection information
URL="https://talkingmoose.jamfcloud.com"
userName="api-editor"
password="P@55w0rd"
# path to list of serial numbers
deviceList="/path/to/file.txt"
@talkingmoose
talkingmoose / Disable Lost Mode.bash
Last active June 3, 2019 19:43
Reads plain text file list of mobile device serial numbers and sends Disable Lost Mode command to each, one at a time.
#!/bin/bash
# server connection information
URL="https://jamfpro.talkingmoose.net:8443"
userName="api-editor"
password="P@55w0rd"
# path to list of serial numbers
deviceList="/path/to/file.txt"
@talkingmoose
talkingmoose / Enable Lost Mode.bash
Last active March 24, 2021 18:36
Reads plain text file list of mobile device serial numbers and sends Enable Lost Mode command to each, one at a time.
#!/bin/bash
# server connection information
URL="https://jamfpro.talkingmoose.net:8443"
userName="api-editor"
password="P@55w0rd"
# Lost Mode messaging
lostModeMsg="This iPad has been reported lost. Please help us return it."
lostModePhone="(612) 555-1234"
@talkingmoose
talkingmoose / JamfHelper countdown dialog.sh
Last active October 25, 2022 23:30
Example of a countdown dialog that can be added to a Jamf Pro policy using a Before script to alert users that something will happen and give them a visual cue that time is running out. Ideal for policies that need to upgrade software such as macOS after gentle reminders and notifications have failed to get their attention.
#!/bin/bash
# Displays a dialog to the end user with a five minute countdown. If the countdown reaches 0:00 or the user clicks the button, the dialog disappears allowing the remainder of the workflow to proceed.
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper \
-windowType utility \
-lockHUD \
-title "macOS Mojave Upgrade" \
-heading "ALERT: Your upgrade is about to start!" \
-description "Your Mac will automatically upgrade its operating system in five minutes and can no longer be deferred. Close and save your work now.
@talkingmoose
talkingmoose / Add Remote Desktop User Account.bash
Created May 23, 2019 04:22
Creates a user account in Microsoft Remote Desktop 10 under Preferences > User Accounts. Modify the necessary items under the "set the keychain item attributes" and run.
#!/bin/bash
# set the keychain item attributes
account=$( uuidgen )
accountName="serveradmin" # aka label
accountPassword="MySecretPassword"
applicationPath="/Applications/Microsoft Remote Desktop.app"
friendlyName="Server Administrator"
service="com.microsoft.rdc.macos"