Skip to content

Instantly share code, notes, and snippets.

@rtrouton
rtrouton / getosversionfromdmg.py
Created September 13, 2016 15:29 — forked from bruienne/getosversionfromdmg.py
Get OS X version from DMG
#!/usr/bin/python
#
# getosversionfromdmg.py
#
# Copyright (c) 2014 The Regents of the University of Michigan
#
# Retrieves the OS version and build from the InstallESD.dmg contained in
# a typical "Install (Mac) OS X <Name>.app" bundle.
#
# To run:
@rtrouton
rtrouton / gist:04b6c31762b84b85eb44d0c59d8e1cd2
Created August 30, 2016 15:58
Mac models not compatible with macOS Sierra
'MacBookPro4,1'
'MacPro2,1'
'MacBookPro5,1'
'MacBookPro1,1'
'MacBookPro5,3'
'MacBookPro5,2'
'iMac8,1'
'MacBookPro5,4'
'iMac5,1'
'iMac5,2'
@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 / LSbootstrapper.py
Created August 28, 2016 19:27 — forked from arubdesu/LSbootstrapper.py
For running at first boot, to enable both location services and whitelist Maps and AutoTimeZone('based on current location')
#!/usr/bin/python
"""Enables location services, allows Maps and Timezone"""
import os
import platform
import subprocess
import sys
try:
sys.path.append('/usr/local/munki/munkilib/')
import FoundationPlist
except ImportError as error:
@rtrouton
rtrouton / autotimezone.py
Created August 26, 2016 16:07 — forked from pudquick/autotimezone.py
Forcing automatic timezone discovery with pyobjc on OS X
# Tested on 10.11
# Assumes your network is in a state to actually do the discovery
# (Generally this means wifi enabled on your device and network stack is up)
#
# Note: When this code exits, it will generate an error message - this is to be expected!
# Error will look like:
# Python[3056:158489] PyObjC: Exception during dealloc of proxy: Cannot remove an observer <TimeZonePref 0x7f846b4b6710>
# for the key path "enabled" from <ATZAdminPrefererences 0x7f846b502a30> because it is not registered as an observer.
#
# This is because we're cheating with the initialization of a TimeZonePref class to get cheap access to
@rtrouton
rtrouton / jss_policies_report.py
Last active May 3, 2016 21:23
Python script to generate list of enabled and disabled policies
#!/usr/bin/env python
import base64
import getpass
import sys
import xml.etree.ElementTree as Et
import urllib
import urllib2
reload(sys)
@rtrouton
rtrouton / gist:86f210edc29f700c000b8fc82b936b92
Created April 14, 2016 14:44
Using BTSync for Casper Replicates
https://docs.google.com/document/d/1wdtJO9TaRn_aGAYCyUizuydWsVVTncx3Ey2V66sjRwI/edit
@rtrouton
rtrouton / filevault2_api.py
Created January 2, 2016 01:15 — forked from pudquick/filevault2_api.py
Programmatic access to usernames, icons, encryption status, and more for FileVault2 for OS X
# This code must run as root
# We're mixing ObjC and C-style dylibs, so this is really fun
# The only reason we're doing this is that the OS is _really really_ picky about trying to do
# ANYTHING with the CoreStorage Family Properties CFDictionary that's in-memory EXCEPT for
# making a mutable copy of it.
# Once we've done that, we can bring it into pyObjC to play nicely with the data.
import objc
@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"
@rtrouton
rtrouton / gist:c05b545d3406de3ca290
Created December 13, 2015 19:27
One-liner for capturing and formatting the output of top on OS X, then exporting to a /tmp/top-output.txt file
/usr/bin/top -l 1 > /tmp/top-scratch.txt && less /tmp/top-scratch.txt >> /tmp/top-output.txt && /bin/rm /tmp/top-scratch.txt