Skip to content

Instantly share code, notes, and snippets.

@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`
@karthikeyan-mac
karthikeyan-mac / disableIPv6.sh
Created June 15, 2023 15:32
Disable IPv6 in all ports
#!/bin/sh
IFS=$'\n'
allPorts=`networksetup -listallnetworkservices | grep -v asterisk`
for port in $allPorts
do
networksetup -setv6off "$port"
echo "$port" IPv6 is Off
done
exit 0
@karthikeyan-mac
karthikeyan-mac / checkDockStatus.sh
Last active June 15, 2023 15:31
Check Dock Status and wait for it to load
#!/bin/bash
#
# Script to check and keep looping till the Dock is loaded
# This can be used to launch or execute app or script after the Dock loads.
#
#
dockStatus=$(pgrep -x Dock)
echo "Waiting for Dock to launch"
while [[ "$dockStatus" == "" ]]
do