Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
talkingmoose / Eraseinstall or Upgrade macOS.zsh
Last active October 24, 2022 21:09
Purpose: Creates a launch daemon and script on target Macs to erase and install or upgrade macOS. Allows the installing policy to finish in a few secconds and report complete rather than never finishing at all.
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Alert! This script will only work with Intel Macs. There is no secure automated
locally-initiated way to trigger an update or upgrade for Apple Silicon Macs.
Those require an MDM command be sent from their Mobile Device Management (MDM)
server.
@talkingmoose
talkingmoose / Download macOS Monterey in Background.zsh
Last active July 17, 2025 22:10
Creates a launch daemon and script on target Macs in a Jamf Pro policy to download the specified macOS installer and update Jamf Pro's inventory. This is preferable to running a command directlt in policy, which can take 30+ minutes to complete, preventing other policies from running. The script self destructs once it sees the installer in the A…
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by:William Smith
Partner Program Manager
Jamf
[email protected]
https://gist.github.com/6b78ba3fc4a6623dbc8225e2df38d570
@talkingmoose
talkingmoose / Jamf Connect License.zsh
Created March 30, 2022 17:11
Checks for an existing Jamf Connect license installed on a Mac and reports license details similar to Jamf Connects' About window.
#!/bin/zsh
# Try to read the com.jamf.connect.login.plist file for license information
licenseInfo=$( /usr/bin/defaults read /Library/Managed\ Preferences/com.jamf.connect.login LicenseFile 2> /dev/null | /usr/bin/base64 --decode )
# If the file doesn't exist, try to read the com.jamf.connect.plist file for license information
if [ "$licenseInfo" = "" ]; then
licenseInfo=$( /usr/bin/defaults read /Library/Managed\ Preferences/com.jamf.connect LicenseFile 2> /dev/null | /usr/bin/base64 --decode )
@talkingmoose
talkingmoose / Monterey-compatible Macs (regex).txt
Last active February 5, 2023 18:45
Regex looks for all Mac models compatible with macOS Monterey. May not be up-to-date with newly released models.
Model information: https://support.apple.com/en-us/HT212551
Published Date: June 24, 2022
Verification: https://regex101.com/r/OozSRv/9
1) Regex matches major identifier — Matches major model identifier numbers based on Apple's knowledge base article (more accurate):
(^Mac1[34]|MacBook(10|9)|MacBookAir(10|[7-9])|Macmini[7-9]|MacPro[6-7]|iMacPro1|iMac(1[6-9]|2[0-2])),\d|MacBookPro1(1,[45]|[2-8],\d)
2) Regex matches current or higher — Matches model identifiers based on Apple's knowledge base article and may match higher versions before this regex is updated (more future-proof).
@talkingmoose
talkingmoose / Set Mobile Device Extension Attribute value.sh
Created February 17, 2022 18:01
Sample Jamf Pro API script to set the value of a mobile device extension attribute "Role" to a value of "Teacher".
#!/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
mobileDeviceID="15"
@talkingmoose
talkingmoose / Create User Account.zsh
Last active December 7, 2024 10:51
Simple script to create a new macOS user account. Will not provide a SecureToken.
#!/bin/zsh
# new user account details
username="lapsadmin"
displayName="LAPS Admin"
password="P@55w0rd"
admin="yes"
hidden="yes"
# determine next available UID
@talkingmoose
talkingmoose / Jamf Pro Provisioning 2.zsh
Created November 16, 2020 06:25
Runs when called by a Jamf Pro policy triggered by Enrollment Complete. Installs third party software that Apple's Volume Purchase Program (VPP) cannot install and runs maintenance routines (bind to Active Directory, set time zone etc.).
#!/bin/zsh
<<'ABOUT_THIS_SCRIPT'
-----------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
[email protected]
@talkingmoose
talkingmoose / SearchLDAP Examples.sh
Created October 22, 2020 22:07
Syntax for looking up user information from a non-bound LDAP directory.
#!/bin/sh
# -H = LDAP URI
# -x = use simple authentication instead of SASL
# -b = search base
# -D = user principal name (UPN) of authenticating user
# -w = password of authenticating user
# look up a user's manager's distinguished name
@talkingmoose
talkingmoose / MegaPKGr.zsh
Last active August 16, 2025 01:51
The pkgbuild binary and Jamf Composer don't support adding single files of 8 GB or more to a package. Some apps like Install macOS Big Sur.app include files larger than 8 GB in their bundles. This script will create a deployable PKG file from apps whose bundles include those large files.
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
[email protected]
https://gist.github.com/e9ed319226c6da30dd633725e48a97b0
@talkingmoose
talkingmoose / Hide Wi-Fi Menu.sh
Last active October 28, 2020 09:18
Quits the Wi-Fi menu item for the current user. Effectively unchecks the "Show Wi-Fi status in menu bar" item in System Preferences > Network.
#!/bin/zsh
# get current logged in user
currentUser=$( /usr/bin/stat -f "%Su" /dev/console )
echo "Current user is $currentUser"
# get current user home folder path
homeFolder=$( /usr/bin/dscl . read /Users/talkingmoose NFSHomeDirectory | /usr/bin/awk -F ": " '{ print $2 }' )
echo "Current user home folder is $homeFolder"