Skip to content

Instantly share code, notes, and snippets.

@karthikeyan-mac
karthikeyan-mac / deleteDevices.sh
Created May 30, 2025 09:27
This script deletes computers or mobile devices from a Jamf Pro instance using their serial numbers. The serial numbers should be listed in a plain text file (one per line).
#!/bin/bash
#
# Script to delete computers or mobile devices in Jamf Pro by serial number list
# Author: Karthikeyan Marappan
# API Role Privileges: Delete Computers and/or Mobile Devices
#
# *** Note: Please TEST the script with Non Prod Environment*** ##
#
###################### CONFIGURABLE VARIABLES ################################
serialNumberList="$HOME/Desktop/sourceList.txt" # Path to text file with serial numbers
#!/bin/bash
################################################################################
# Description:
# Adds or removes a computer (by Serial Number) to/from a static group
# in Jamf Pro using the OAuth 2.0 API with client credentials.
#
# Prerequisites:
# - Jamf Pro instance must support Bearer Token API authentication.
# - client_id and client_secret must belong to an API role with proper privileges.
# - API Privileges : Update Static Computer Groups, Read Static Computer Groups
#!/bin/bash
# Karthikeyan Marappan
# Slack Notification from Jamf Pro Policy
# Exit immediately on error
set -e
# --- Input Parameters ---
SLACK_WEBHOOK_URL="<SLACKWEBHOOKURL>"
# GitLab Runner config for Jamf Pro Notifications Alerter
# https://github.com/alectrona/jamf-pro-notifications-alerter
# .gitlab-ci.yml
stages:
- development
- production
development:
stage: development
script:
@karthikeyan-mac
karthikeyan-mac / UpdateJamfStaticGroup.sh
Created April 2, 2025 09:39
This script reads a list of serial numbers from a file and updates a Static Computer Group in Jamf Pro.
#!/bin/bash
#
# Script to update (add/remove) the existing Computer Static Group from the list of serial numbers.
# Karthikeyan Marappan
# API Role Privileges: Update Static Computer Groups
###################### CONFIGURABLE VARIABLES ################################
serialNumberList="$HOME/Desktop/sourceList.txt" # Path to plain text file with serial numbers
Jamf_URL="https://karthikeyan.jamfcloud.com" # Your Jamf Pro URL
Jamf_URL="${Jamf_URL%/}" # Remove trailing slash if present
#!/bin/bash
#
# This script retrieves the Mac Hardware UUID, fetches the corresponding Computer ID from Jamf Pro,
# checks for any failed MDM commands, and clears them if found.
#
# Uses JAMF API Client and Roles.
# Add Parameter 4 & 5 with API Client ID & Client Secret when running in JAMF Policy.
# API Role Privileges Required: Read Computers, Flush MDM Commands.
#
# Karthikeyan Marappan
@karthikeyan-mac
karthikeyan-mac / setRecoveryLock.sh
Created March 13, 2025 14:12
Recovery Lock Enablement in macOS Using the Jamf Pro API
#!/bin/zsh
# Script to Set/Remove Recovery Lock on Apple Silicon Macs using the Jamf API.
# Works based on the 'lockMode' variable (Set/Remove) to configure Recovery Lock.
#
# Key Functionalities:
# - Retrieves the Mac's serial number.
# - Generates a 26-digit random Recovery Lock password.
# - Uses JAMF API Roles and Clients
# - Uses Jamf Pro API to:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>InstallMacOSMajorUpgrades</key>
<true/>
<key>InstallRapidSecurityResponses</key>
<true/>
<key>InstallNonSystemUpdatesWithoutRestarting</key>
<true/>
#!/bin/bash
# Extension Attribute (EA) script to inventory software update deferral settings on macOS
# Author: Karthikeyan M
# Optimized Version
# Function to retrieve values from macOS preferences
get_pref() {
osascript -l JavaScript << EOS
ObjC.import('Foundation')
ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('com.apple.applicationaccess').objectForKey('$1'))
@karthikeyan-mac
karthikeyan-mac / forceDelayedMajorSoftwareUpdatesEA.sh
Last active September 30, 2023 10:59
JAMF EA to inventory the forceDelayedMajorSoftwareUpdates and enforcedSoftwareUpdateMajorOSDeferredInstallDelay value
#!/bin/bash
# EA to inventory the forceDelayedMajorSoftwareUpdates and enforcedSoftwareUpdateMajorOSDeferredInstallDelay value
# Karthikeyan M
# 25-Sep-23
#Software Update (com.apple.applicationaccess):
forceDelayedMajorSoftwareUpdates=`osascript -l JavaScript << EOS
ObjC.import('Foundation')
ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('com.apple.applicationaccess').objectForKey('forceDelayedMajorSoftwareUpdates'))
EOS`