Skip to content

Instantly share code, notes, and snippets.

sysadminctl is a tool Apple introduced in 10.10 for working with system user accounts. In 10.13,
sysadminctl is Apple's recommended tool for working with user accounts in the CLI, replacing functionality
that has long been provided by dscl and adds new features available only in 10.13.
sysadminctl can be used to change user passwords, create new users (including automatically provisioning
the user home folder) or check the status of a new-to-10.13 security feature named SecureToken.
SecureToken is a user attribute like password type or user home location. SecureToken is not publicly
documented by Apple so it is not possible to provide a full technical description, but in practice one
needs only to know if a user has SecureToken or not. Having SecureToken set signifies that a user can
unlock a FileVault-encrypted volume. Without the SecureToken bit on a user account, that user will not
@rtrouton
rtrouton / gist:3ac68ac3770ab23ebae354c581f526b7
Last active April 23, 2024 01:17
MigrateADMobileAccountToLocalAccount.command script
#!/bin/bash
# Modified 4/5/2019
Version=1.4
# Original source is from MigrateUserHomeToDomainAcct.sh
# Written by Patrick Gallagher - https://twitter.com/patgmac
#
# Guidance and inspiration from Lisa Davies:
# http://lisacherie.com/?p=239
#
# Modified by Rich Trouton
@rtrouton
rtrouton / gist:4ff699b3f7660ae06a13
Created December 27, 2014 15:59
Software Update keys in Yosemite's /Library/Preferences/com.apple.SoftwareUpdate.plist
Automatically check for updates:
Enable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled -bool TRUE
Disable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled -bool FALSE
Download newly available updates in the background:
Enable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool TRUE
Disable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool FALSE
@rtrouton
rtrouton / pkg_cheatsheet.md
Created November 14, 2022 22:00
Working with Apple pkgs

Mac Packaging Cheatsheet

Create a component pkg from a DMG

pkgbuild --component /Volumes/ApplicationName/*.app --install-location \
    /Applications ApplicationName-Version.pkg

Install pkg from command line

How to Download iOS Simulator (Xcode) in Command Line and Install it

For faster connection speed and more flexibility.

Steps

  1. Start Xcode in command line by running this in commandline /Applications/Xcode.app/Contents/MacOS/Xcode
  2. Start downloading of the simulator
  3. Cancel it. YES CANCEL IT!
  4. You will get a message like this:
@rtrouton
rtrouton / gist:8016797
Last active September 28, 2023 12:54
createmyguest.sh script, original by nbalonso (https://gist.github.com/nbalonso/5696340)
#!/bin/bash
# Original script by Noel B. Alonso: https://gist.github.com/nbalonso/5696340
#variables
DSCL="/usr/bin/dscl"
SECURITY="/usr/bin/security"
LOGGER="/usr/bin/logger"
# Determine OS version
@rtrouton
rtrouton / gist:e6cf0f4064aea52fac2e5116c4b05f2e
Created August 30, 2016 15:56
Sierra compatible Macs, sorted by Model ID and board ID
MacBook9,1: 'Mac-9AE82516C7C6B903'
iMac14,1: 'Mac-031B6874CF7F642A'
iMac10,1: 'Mac-F2268DC8'
MacBookPro8,1: 'Mac-50619A408DB004DA'
MacBook6,1: 'Mac-F22C8AC8'
MacBookPro10,2: 'Mac-AFD8A9D944EA4843'
iMac12,2: 'Mac-942B59F58194171B'
iMac14,2: 'Mac-27ADBB7B4CEE8E61'
MacBook8,2: 'Mac-F305150B0C7DEEEF'
MacBookAir6,1: 'Mac-35C1E88140C3E6CF'
@rtrouton
rtrouton / gist:7238371
Last active March 30, 2023 15:56
Script to handle unbinding your Mac from one OpenLDAP server and moving to another. Also handles AD domains differently. If you are adapting this for your own use, run a search and replace for the following: "dc=replaceme,dc=org" (no quotes) You'll need to replace that with your own LDAP search base "ldap.server.goes.here" (no quotes) You'll nee…
#!/bin/sh
# Determine OS version
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
# Environment settings
LDAPdomain="new_ldap_server_here" # Fully qualified DNS of new LDAP server
oldLDAPdomain="old_ldap_server_here" # Fully qualified DNS of old LDAP server
oldADdomain="olddomain.com" # Fully qualified DNS name of the old Active Directory Domain
oldADdomainname="OLDDOMAIN" # Name of the old AD Domain as specified in the search paths
@rtrouton
rtrouton / gist:6552a3010931f7a5b5ae
Created May 11, 2015 12:57
Script to install the latest available version of Adobe Flash for OS X. Includes check of the Developer ID Installer certificate to verify it was signed by Adobe.
#!/bin/bash
# This script downloads and installs the latest Flash player for compatible Macs
# Determine OS version
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
# Determine current major version of Adobe Flash for use
# with the fileURL variable
@rtrouton
rtrouton / gist:fd965b16a9b4a7dc5d89
Created December 22, 2015 00:25
Script to fix Casper MDM
#!/bin/bash
# Identify location of jamf binary.
jamf_binary=`/usr/bin/which jamf`
if [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ ! -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/sbin/jamf"
elif [[ "$jamf_binary" == "" ]] && [[ ! -e "/usr/sbin/jamf" ]] && [[ -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/local/bin/jamf"