Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
talkingmoose / Change Jamf Pro Activation Code.zsh
Created Jun 27, 2022
Programmatic method to change a Jamf Pro server's Activation Code via the Classic API for Jamf Pro 10.35.0 and later.
View Change Jamf Pro Activation Code.zsh
#!/bin/zsh
# server connection information
URL="https://jss.talkingmoose.net:8443"
userName="JSSAPI-Editor"
password="password"
# use base64 to encode credentials
encodedCredentials=$( printf "$userName:$password" | iconv -t ISO-8859-1 | base64 -i - )
@talkingmoose
talkingmoose / Speed Dating for Mac Admins.md
Last active Jun 20, 2022
Resources for my Penn State 2022 MacAdmins Campfire presentation on June 2
View Speed Dating for Mac Admins.md

Speed Dating for Mac Admins

Terminal Login Banner

Last login: Wed Jun  1 23:03:39 on ttys000


                        'c.            Logged in as: bill.smith
 ,xNMM. ---------------------------------
@talkingmoose
talkingmoose / RemoveApplication.zsh
Created May 27, 2022
Remove a drag-and-drop application before performing another task such as a software update.
View RemoveApplication.zsh
#!/bin/zsh
<<ABOUT_THIS_SCRIPT
-----------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/bd4abab222685c4e3781967a4d0491f6
View Terminal Login Banner.zsh
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-----------------------------------------------------------------------
Written by:William Smith
Partner Program Manager
Jamf
bill@talkingmoose.net
https://gist.github.com/talkingmoose/15f055885b51cc8cb0bc7aad021acead
@talkingmoose
talkingmoose / RemoveUsersFromAdmin.zsh
Last active Jun 7, 2022
Removes all users with UIDs greater than 500 from local admin group.
View RemoveUsersFromAdmin.zsh
#!/bin/zsh
# these local accounts will not be removed from admins
# one account name per line; keep the beginning and closing quotes
exceptionsList="talkingmoose
bill.smith
oszein
jamfadmin"
@talkingmoose
talkingmoose / Eraseinstall or Upgrade macOS.zsh
Last active May 24, 2022
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.
View Eraseinstall or Upgrade macOS.zsh
#!/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
Created Apr 17, 2022
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…
View Download macOS Monterey in Background.zsh
#!/bin/zsh
:<<ABOUT_THIS_SCRIPT
-------------------------------------------------------------------------------
Written by:William Smith
Partner Program Manager
Jamf
bill@talkingmoose.net
https://gist.github.com/6b78ba3fc4a6623dbc8225e2df38d570
@talkingmoose
talkingmoose / Jamf Connect License.zsh
Created Mar 30, 2022
Checks for an existing Jamf Connect license installed on a Mac and reports license details similar to Jamf Connects' About window.
View Jamf Connect License.zsh
#!/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 Jun 6, 2022
Regex looks for all Mac models compatible with macOS Monterey. May not be up-to-date with newly released models.
View Monterey-compatible Macs (regex).txt
Model information: https://support.apple.com/en-us/HT212551
Published Date: March 18, 2022
Verification: https://regex101.com/r/OozSRv/6
1) Regex matches major identifier — Matches major model identifier numbers based on Apple's knowledge base article (more accurate):
(^Mac13|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 Feb 17, 2022
Sample Jamf Pro API script to set the value of a mobile device extension attribute "Role" to a value of "Teacher".
View Set Mobile Device Extension Attribute value.sh
#!/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"