#!/bin/bash
###################################################################
# General
###################################################################
# reset dock icons to factory set
defaults delete com.apple.dock; killall Dock
# disable remote optical disc in Finder
sudo defaults write /Library/Preferences/com.apple.NetworkBrowser EnableODiskBrowsing -bool false; killall Finder
# max out cpu
yes > /dev/null & yes > /dev/null & yes > /dev/null & yes > /dev/null &
# max out cpu (kill process)
killall yes
# get a list of app architecture types (macOS 11 and up)
system_profiler SPApplicationsDataType >~/Desktop/MyApps.txt
# menubar clock (macOS 11 and up)
# Tue Nov 24 4:53 PM
defaults write com.apple.menuextra.clock DateFormat -string “EEE MMM d h:mm a”
# creating macos install media
sudo /Volumes/Install\ macOS\ Big\ Sur/Install\ macOS\ Big\ Sur.app/Contents/Resources/createinstallmedia –nointeraction –volume /Volumes/usb1
###################################################################
# APFS
###################################################################
# create an apfs local snapshot
tmutil snapshot
# list local snapshots to verify
tmutil listlocalsnapshots /
###################################################################
# Apple Remote Desktop (ARD)
###################################################################
# get RAM info
system_profiler SPMemoryDataType
#get CPU info
system_profiler SPHardwareDataType
# computer info 1
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -computerinfo -set1 -1 [text here]
# computer info 2
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -computerinfo -set2 -2 [text here]
# computer info 3
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -computerinfo -set3 -3 [text here]
# computer info 4
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -computerinfo -set4 -4 [text here]
###################################################################
# FileVault
###################################################################
# validate filefault recovery key
sudo fdesetup validaterecovery
# unlock a filevault protected volume to check the recovery key
diskutil apfs unlockVolume /dev/[disk_name]
###################################################################
# Networking
###################################################################
# flush dns
sudo killall -HUP mDNSResponder
# sync time with apple
sudo ntpdate -u time.apple.com
###################################################################
# Quarantine
###################################################################
# fix for hdri browser
xattr -d com.apple.quarantine /Applications/MAXON/Cinema\ 4D\ R20/plugins/HDRI\ Browser/HDRI\ Browser.xlib
# cinema 4d r20 installation error
xattr -rc [path to dmg]
###################################################################
# SMB
###################################################################
# view smb connection stats
smbutil statshares -a
# disable SMB signing (10.13.4 and earlier)
printf “[default]\nsigning_required=no\n” | sudo tee /etc/nsmb.conf >/dev/null
# verify disable SMB signing
cat /etc/nsmb.conf
# force unmount of SMB share
umount -f /Volumes/[name]
###################################################################
# Software Update
###################################################################
# install all updates (force reboot since -R flag does not work)
softwareupdate -i -a -R && reboot now
# remove apple id upgrade notification (app store account)
defaults delete com.apple.systempreferences AttentionPrefBundleIDs
# block macos upgrades
sudo softwareupdate –ignore “macOS Big Sur”
# reset blocked macos upgrades
sudo softwareupdate –reset-ignored
###################################################################
# Spotlight
###################################################################
# rebuild spotlight on boot drive
sudo mdutil -E /
# disable spotlight
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
###################################################################
# Users & Groups
###################################################################
# view which accounts are admins
dscl . -read /Groups/admin
# list logged in users
last | grep “logged in”
# change password of user account (must pause bash history or will be stored in plain text)
dscl . -passwd /Users/[username] [oldpassword] [newpassword]
# change user account to admin
sudo dseditgroup -o edit -a [username] -t user admin
# change user account to admin (newer)
dscl . -append /groups/admin GroupMembership [username]
# change user account to standard
sudo dseditgroup -o edit -d [username] -t user admin
# remove user account picture
dscl . delete /Users/$USER jpegphoto; dscl . delete /Users/$USER Picture