Skip to content

Instantly share code, notes, and snippets.

@haircut
haircut / rename-computer-from-google-sheet.zsh
Created September 2, 2022 00:58
A minimal reimplementation of my Python script that renames computers using a Google sheet as a data source.
#!/bin/zsh
# Replace with the ID of your Google Sheet
DOCUMENT_ID="XXX"
SHEET="https://docs.google.com/spreadsheets/d/${DOCUMENT_ID}/edit#gid=0/export?format=csv&id=${DOCUMENT_ID}&gid=0"
/usr/bin/curl -L "${SHEET}" -o /tmp/serial-sheet.csv
/usr/local/bin/jamf setComputerName -fromFile /tmp/serial-sheet.csv
@haircut
haircut / Disable-iCloud-Private-Relay.mobileconfig
Created October 28, 2021 00:24
Disables the iCloud Private Relay feature.
<?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>PayloadContent</key>
<array>
<dict>
<key>PayloadDisplayName</key>
<string>Restrictions</string>
<key>PayloadIdentifier</key>
@haircut
haircut / TCC-Testing-Privacy-Policy.mobileconfig
Created August 23, 2018 02:11
Largely disable consent prompts in a Jamf environment.
<?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>PayloadContent</key>
<array>
<dict>
<key>Services</key>
<dict>
<key>Accessibility</key>
@haircut
haircut / Defer-Software-Updates.mobileconfig
Last active August 17, 2018 17:12
Manage ONLY Software Update Deferral delay
<?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>PayloadContent</key>
<array>
<dict>
<key>PayloadDescription</key>
<string></string>
<key>PayloadDisplayName</key>
@haircut
haircut / tcc-reset.py
Last active December 21, 2023 10:09
Completely reset TCC services database in macOS
#!/usr/bin/python
"""
Completely reset TCC services database in macOS
Note: Both the system and individual users have TCC databases; run the script as both
a user and as root to completely reset TCC decisions at all levels.
2018-08-15: Resetting the 'Location' service fails; unknown cause
2018-08-16: Confirmed the 'All' service does not really reset _all_
services, so individual calls to each service is necessary.
@haircut
haircut / forget-saved-ssids.py
Last active September 24, 2018 19:58
Forget all saved SSIDs with whitelisting
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Forget saved SSIDs with whitelisting
This script removes ALL saved SSIDs on a Mac except for those configured in a
whitelistsee SSID_WHITELIST variable below.
Thanks to @sepiemoini for suggestion of "MERGE_CURRENT_SSID" behavior
@haircut
haircut / modify-system-preferences-authorizations.py
Last active June 5, 2023 16:27
Backs up authdb, then modifies them so users can modify Energy Saver, Network, Printers & Scanners, Date & Time, Time Machine
#!/usr/bin/python
'''
Modifies authorizations database to allow standard users to change select
system preferences.
A great guide to available authorization rights can be found at:
https://www.dssw.co.uk/reference/authorization-rights/index.html
USE AT YOUR OWN RISK
'''
@haircut
haircut / rename-computer.py
Last active February 1, 2023 09:57
Rename a computer using the Jamf binary and a Google Sheet - full details: https://www.macblog.org/post/automatically-renaming-computers-from-a-google-sheet-with-jamf-pro/
#!/usr/bin/python
'''
Rename computer from remote CSV using Jamf binary
Pass in the URL to your remote CSV file using script parameter 4
The remote CSV could live on a web server you control, OR be a Google Sheet
specified in the following format:
https://docs.google.com/spreadsheets/u/0/d/<document ID>/export?format=csv&id=<document ID>&gid=0
@haircut
haircut / bash-multiple-jamf-policies.sh
Last active December 28, 2020 16:09
Running multiple Jamf policies in bash or python; minimal examples
#!/bin/bash
# Policy IDs or custom trigger names
# Bash arrays are specified like the provided example; surround custom triggers with
# quotes, and leave policy ids as "bare" integers
POLICIES=( "custom" "triggers" 523 32 )
for i in "${POLICIES[@]}"; do
# test if array element is an integer, ie. a policy id
if [ "$i" -eq "$i" ] 2>/dev/null