Skip to content

Instantly share code, notes, and snippets.

View lucascantor's full-sized avatar

Lucas Cantor lucascantor

View GitHub Profile
@lucascantor
lucascantor / resetMacintoshHD.sh
Last active February 10, 2018 18:26
Overwrite the macOS disk partition table and re-partition over encrypted data without causing excessive wear by explicitly erasing the full SSD
# Replace N in diskN with the disk number of your choice
# Use "diskutil list" to confirm, and ALWAYS back up your data
dd if=/dev/zero of=/dev/diskN bs=512 count=1
diskutil partitionDisk /dev/diskN 1 GPT APFS "Macintosh HD" 100%
@lucascantor
lucascantor / enableRemoteManagement.sh
Last active February 10, 2018 18:29
Apple Remote Desktop can be enabled and configured via the command line
# e.g., Grant all remote control privileges to user johnsmith:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users johnsmith -privs -all -restart -agent -menu
# e.g., Revoke all remote control privileges for all users, to clear unwanted settings:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -access -off
# e.g., Grant ability to request screen sharing only, with explicit confirmation from the current user:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -allowAccessFor -specifiedUsers -clientopts -setreqperm -reqperm yes -setvnclegacy -vnclegacy no -setmenuextra -menuextra no
@lucascantor
lucascantor / authrestart.sh
Last active September 30, 2020 15:11
The fdesetup utility can be used to remotely restart a Mac without needing physical in-person keyboard access to unlock FileVault on the next boot only
fdesetup authrestart
@lucascantor
lucascantor / authrestart.cmd
Last active January 27, 2018 05:37
Restart Windows without needing to unlock BitLocker on next boot only
PowerShell -Command "Suspend-BitLocker -MountPoint "C:" -RebootCount 1"
shutdown /r /f
@lucascantor
lucascantor / addFileVaultUser.sh
Last active February 17, 2018 16:40
Add user to those able to unlock FileVault
fdesetup add -usertoadd <username>
@lucascantor
lucascantor / removeFileVaultUser.sh
Last active February 17, 2018 16:40
Remove user from those able to unlock FileVault
fdesetup remove -user <username>
@lucascantor
lucascantor / checkGateKeeper.sh
Last active April 26, 2022 07:56
Manage GateKeeper
# check current GateKeeper configuration status
spctl --status
@lucascantor
lucascantor / installPkg.sh
Last active March 3, 2018 20:30
User installer command line utility to install a .pkg installer file on macOS
installer -pkg /path/to/pkg/software/installation/file.pkg -target /
@lucascantor
lucascantor / pmsetSchedule.sh
Last active March 10, 2018 17:37
Schedule repeating reboots, replacing 'MTWRFSU 04:00:00' with desired day(s) of week and time of day
pmset repeat restart MTWRFSU 04:00:00
@lucascantor
lucascantor / createMacOSInstallMedia.sh
Last active March 17, 2018 17:53
Create a bootable macOS installation disk
/path/to/macOS/installer.app/Contents/Resources/createinstallmedia --volume /path/to/installation/media/volume --applicationpath /path/to/macOS/installer.app --nointeraction