Skip to content

Instantly share code, notes, and snippets.

@macsimom
macsimom / demobilize_user.py
Created May 31, 2022 21:40
Demobilize a mobile user on macOS
#!/usr/local/munki/munki-python
#
# MIT License
#
# Copyright (c) 2022 Simon Andersen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// MIT License
//
// Copyright (c) 2022 Simon Andersen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@macsimom
macsimom / main.m
Last active January 20, 2022 03:00
openwithrosetta - a tool to check the box "Open with Rosetta" on Apple Silicon Big Sur Macs
//
// main.m
// openwithrosetta
//
// Created by Simon Andersen on 13/09/2021.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@macsimom
macsimom / promote_personal_recovery_key_to_admin_user.sh
Last active July 8, 2021 23:06
Given a valid personal recovery key and an existing user this script elevates the PRK to an actual user and destroys and re-creates the given user with a default password and secure token.
#!/bin/bash
#
# Call this script with the arguments [personal recovery key] [the name of a user to "reset"]
# i.e. "promote_personal_recovery_key_to_admin_user.sh 6323-AHJD-1231-4234-GHJ1-FH23 user1"
# a new user called "another" user is generated. It has the prk with a dash at the end for a password
# a new prk is generated and the user to reset is re-created with the password "password" and a
# newly minted secure token
#set -x
@macsimom
macsimom / EnableARD.sh
Created March 23, 2021 16:40
A short script to enable Apple Remote Desktop (aka. Remote Management) for a given user.
#!/bin/zsh
function ENABLEARD(){
dscl . -create "/Users/${1}" dsAttrTypeNative:naprivs -1073741569
touch "/Library/Application Support/Apple/Remote Desktop/RemoteManagement.launchd"
if ! launchctl list|grep -q com.apple.screensharing ; then
launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
fi
echo "Enabled Apple Remote Desktop Management for ${1}"
}
@macsimom
macsimom / build_a_booter_for_fusion.sh
Last active November 18, 2020 12:57
A quick script to convert a macOS recovery partition to a bootable iso intended for VMware Fusion
#!/bin/bash
# Download the script from https://gist.github.com/macsimom/982d507ff94767428e4832ef0fdbdf0c
# Open Terminal
# diskutil list
# Find the device identifer of the recovery partition, eg. "disk1s3"
# call the script with the device indentifier
# bash build_a_booter_for_fusion.sh disk1s3
# An iso file is built at /Users/Shared
#
#!/usr/bin/python
# Version 0.1
# This was (re)written quick and dirty. And by dirty I mean embarrasing.
import subprocess
import tempfile
import os
import re
dfsroot="//example.com/dfs"
dfsrootserveraddress='dfs01.example.com'
@macsimom
macsimom / Disable_macOS_upgrade.sh
Created September 4, 2019 17:39
Call it with sudo bash Disable_macOS_upgrade.sh disable Catalina
#!/bin/bash
# Call it with eg. sudo bash Disable_macOS_upgrade.sh disable Catalina
disable_osxnotification() {
if [ -d /Library/Bundles/OSXNotification.bundle ]; then
hdiutil create -format UDZO -fs hfs+ -srcfolder /Library/Bundles/OSXNotification.bundle /Library/Bundles/OSXNotification
rm -rf /Library/Bundles/OSXNotification.bundle
fi
if [[ ! -e /Library/Bundles/OSXNotification.bundle ]]; then
touch /Library/Bundles/OSXNotification.bundle
@macsimom
macsimom / macos_vm_kickstarter.sh
Last active September 9, 2019 20:27
Ever minimizing the steps to get Catalina Beta running in VMware Fusion
#!/bin/bash
####
#
# Prerequisite steps:
#
# 1 - Download a copy of the Install macOS app
# 2 - Mount the InstallESD.dmg and extract the kernel file with Pacifist from Core.pkg
# 3 - Create a new macOS 10.14 vm (give it more ram than the standard 2 GB)
#
@macsimom
macsimom / NoMAD_shares.sh
Last active September 11, 2019 09:33
Query a domain server or multiple domain servers for fileshares. Try and mount each share. If accessible then add to NoMAD menu.
#!/bin/bash
SERVERS="server1 server2"
# Maybe use commandline arguments as servers: SERVERS="$@"
TEMPPLIST=$(mktemp -t nstl)
cat <<EOF > "$TEMPPLIST"
<?xml version="1.0" encoding="UTF-8"?>