Skip to content

Instantly share code, notes, and snippets.

View AndrewWCarson's full-sized avatar
🐦

Andrew Worth Carson AndrewWCarson

🐦
View GitHub Profile
@AndrewWCarson
AndrewWCarson / Get All Users AppleID.sh
Last active March 7, 2019 19:40
Iterate through all login users on the device and output their Apple ID.
#!/bin/bash
# (C) Andrew Worth Carson
# MIT License: https://andrewworthcarson.com/mit_license.html
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//')
appleid=$(dscl . readpl "${userHome}" dsAttrTypeNative:LinkedIdentity appleid.apple.com:linked\ identities:0:full\ name 2> /dev/null | awk -F'full name: ' '{print $2}')
if [[ "${appleid}" == "" ]]; then
echo "No AppleID for user:${user}"
@AndrewWCarson
AndrewWCarson / speedtest_api_on_all_devices.py
Last active November 5, 2018 21:53
Run a speedtest-cli across all devices in Addigy.
#!/usr/bin/python
# Libraries
import sys
import requests
import json
import re
# Constants
client_id = 'YOUR CLIENT ID HERE'
@AndrewWCarson
AndrewWCarson / Export Chrome History.sh
Last active August 23, 2018 04:52
Iterate through all users and export their Chrome history to .csv in /tmp
#!/bin/bash
# (C) Andrew Worth Carson
# MIT License: https://andrewworthcarson.com/mit_license.html
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//')
if cp "${userHome}/Library/Application Support/Google/Chrome/Default/History" "/tmp/${user}-History"; then
if sqlite3 "/tmp/${user}-History" <<EOF
.headers on
@AndrewWCarson
AndrewWCarson / Get Current Users AppleID.sh
Last active August 23, 2018 04:33
Grabs the currently logged in user and checks to see if they have an associated AppleID.
#!/bin/bash
# (C) Andrew Worth Carson
# MIT License: https://andrewworthcarson.com/mit_license.html
username=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
if [[ "${username}" == "" ]]; then
echo "No user currently logged in."
exit 1
else
@AndrewWCarson
AndrewWCarson / Iterate Through Users.sh
Last active July 19, 2022 17:03
Iteration through all macOS users & home directories
#!/bin/bash
# (C) Andrew Worth Carson
# MIT License: https://andrewworthcarson.com/mit_license.html
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//')
echo "$user:$userHome"
done
@AndrewWCarson
AndrewWCarson / Disable Icon Preview High Sierra.sh
Last active August 23, 2018 04:50 — forked from MacChuck/DisableIconPreviewHighSierra.sh
Disables icon previews and preview column for all users in macOS High Sierra.
#!/bin/bash
# This disables the Column View icon in Finder for all users
# Change file separators so we don't get hung up on spaces
OIFS=$IFS
IFS=$'\n'
# Iterate through all users
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
@AndrewWCarson
AndrewWCarson / Install Profile Per User.sh
Created January 8, 2018 21:59
Installs a macOS profile for each user on the device.
#!/bin/bash
# The goal of this script is to install a profile for each login user on a Mac
# device, taking into consideration the discrepancies between the profiles tool
# on High Sierra versus older versions.
# The should combine to create the absolute path of the profile
profileName='/test cert.mobileconfig'
profilePath='/Library/Addigy/ansible/packages/Certificate Test'
@AndrewWCarson
AndrewWCarson / Install With Prompt.sh
Last active May 17, 2019 00:22
Install workflow for Addigy that prompts the end-user to close the application.
#!/bin/bash
# (C) Andrew Worth Carson
# MIT License: https://andrewworthcarson.com/mit_license.html
APP="Google Chrome"
# Check if the app in question is running.
isRunning=$(ps aux | grep -v grep | grep "${APP}")
while [ "${isRunning}" != "" ]; do
#!/bin/sh
#set -x
TOOL_NAME="Microsoft Office 2011 for Mac Removal Tool"
TOOL_VERSION="1.4"
## Copyright (c) 2017 Microsoft Corp. All rights reserved.
## Scripts are not supported under any Microsoft standard support program or service. The scripts are provided AS IS without warranty of any kind.
## Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a
## particular purpose. The entire risk arising out of the use or performance of the scripts and documentation remains with you. In no event shall
@AndrewWCarson
AndrewWCarson / Enable Fast User Switching.sh
Last active November 5, 2021 05:31
Enable Fast User Switching on macOS 10.12
#!/bin/bash
# (C) Andrew Worth Carson
# MIT License: https://andrewworthcarson.com/mit_license.html
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//')
if [ "$(defaults read "${userHome}/Library/Preferences/com.apple.systemuiserver.plist" 2> /dev/null | grep -i user.menu)" == "" ]; then
touch "${userHome}/Library/Preferences/com.apple.systemuiserver.plist"
defaults write "${userHome}/Library/Preferences/com.apple.systemuiserver.plist" menuExtras -array-add '<string>/System/Library/CoreServices/Menu Extras/User.menu</string>'