Skip to content

Instantly share code, notes, and snippets.

View bwmorales's full-sized avatar

Benjamin Morales bwmorales

  • Madison, WI
View GitHub Profile
@bwmorales
bwmorales / checkOfficeUtilizationCustomFact.sh
Created August 27, 2019 03:20
macOS: Addigy custom fact for checking if people are using Office 365
#!/bin/bash
currentDate=$(date "+%s")
applicationList=(
"/Applications/Microsoft Word.app"
"/Applications/Microsoft Excel.app"
"/Applications/Microsoft PowerPoint.app"
"/Applications/Microsoft Outlook.app"
"/Applications/Microsoft OneNote.app"
"/Applications/Microsoft Teams.app"
)
@bwmorales
bwmorales / checkOfficeUtilization.sh
Created August 27, 2019 03:19
macOS: check whether office applications have been opened in the last 30 days.
#!/bin/bash
currentDate=$(date "+%s")
applicationList=(
"/Applications/Microsoft Word.app"
"/Applications/Microsoft Excel.app"
"/Applications/Microsoft PowerPoint.app"
"/Applications/Microsoft Outlook.app"
"/Applications/Microsoft OneNote.app"
"/Applications/Microsoft Teams.app"
"/Applications/Yammer.app"
@bwmorales
bwmorales / removeApplicationsFromBackupAndSync.sh
Last active August 24, 2019 16:38
Because this one time I was really stupid and let a client tell me to try backing up /Applications on macOS.....
#!/bin/bash
backupAndSyncConfig="Library/Application Support/Google/Drive/user_default/sync_config.db"
removeDataKeys="DELETE FROM data WHERE data_value IS '/Applications';"
removeDataValues="DELETE FROM data WHERE data_key IS '/Applications';"
loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
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]*//')
sqlite3 "${userHome}/${backupAndSyncConfig}" "$removeDataKeys"
@bwmorales
bwmorales / setpreferredwirelessnetwork.sh
Last active November 29, 2021 17:17
for macOS, set your preferred wireless network
#!/bin/bash
preferredNetwork="$1"
securityType="$2"
# For securityType,
# use OPEN for none,
# WPA for WPA Personal,
# WPA2 for WPA2 Personal,
# WPA/WPA2 for WPA/WPA2 Personal,
# WPAE for WPA Enterprise,
ln "$(lsof -p $(ps -ax | grep storedownloadd | grep -v grep | awk '{ print $1 }') | awk '{ print $9 }' | grep -E '^/private/var/folders/.*/com\.apple\.appstore.*\.pkg$')" ~/Desktop/AppStoreApp.pkg
#!/bin/bash
# Example given with Wireshark. Script tests ping times for Wireshark's mirrors and selects the fastest.
MIRRORS=(
'1.as.dl.wireshark.org'
'1.eu.dl.wireshark.org'
'1.na.dl.wireshark.org'
'2.na.dl.wireshark.org'
# 'www.wireshark.org'
/sbin/route get 1.1.1.1 | /usr/bin/grep 'interface: ' | /usr/bin/sed 's/.*interface: //'
@bwmorales
bwmorales / rmSMB_Illegals.sh
Last active June 29, 2018 18:10
Swap out those pesty SMB illegals with benign characters!
#!/bin/bash
# USAGE: ./rmSMB_Illegals.sh path
# Find searches through each file on a filesystem and passes the filenames to a
# function that tests for the presence of illegal characters and remediates.
# Bad characters are either removed or replaced with a ``-''.
# This has been tested on APFS on macOS 10.13.5. It'd be pretty safe to run this
# on a mounted volume, but it'd be nicer to test on Synology Linux and have it
/usr/bin/say "This test worked."
#!/usr/bin/env bash
#
# Remove Microsoft Office 2016 from macOS
# Store file in a place that is readable by all users
export LOG_FILE="/Library/Logs/Microsoft/uninstall.log"
export TODAY=$(date +"%Y-%m-%d")
export RED='\033[0;31m'
export GREEN='\033[0;32m'
export YELLOW='\033[0;33m'