Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
talkingmoose / Delete Outlook Items.scpt
Created November 29, 2015 01:43
Deletes any selected items (messages, events, contacts, etc.) from Outlook.
tell application "Microsoft Outlook"
set theSelection to the selection
repeat with anItem in theSelection
delete anItem
end repeat
end tell
@talkingmoose
talkingmoose / com.talkingmoose.addipfwrule.plist
Created January 17, 2013 18:23
Launchd item to add a firewall rule via ipfw.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.318.ipfwadditions</string>
<key>ProgramArguments</key>
<array>
<string>ipfw</string>
<string>add</string>
@talkingmoose
talkingmoose / Change OS X Password
Last active May 22, 2016 17:13
Opens the Users & Groups pane in System Preferences and clicks the Change Password button
tell application "Finder" to open file "Accounts.prefpane" of (path to system preferences)
tell application "System Events"
tell application process "System Preferences"
delay 1
click button "Change Password…" of tab group 1 of window "Users & Groups"
end tell
end tell
@talkingmoose
talkingmoose / osascriptTextandButton.sh
Last active September 15, 2016 21:54
Method for returning both text and button from osascript dialog
#!/bin/sh
results=$( osascript -e "display dialog \"Text and Buttons!\" default answer \"Some text...\" buttons {\"Cancel\",\"OK\"} default button {\"OK\"}" )
theButton=$( echo "$results" | awk -F "button returned:|," '{print $2}' )
theText=$( echo "$results" | awk -F "text returned:" '{print $2}' )
exit 0
@talkingmoose
talkingmoose / ChangeOutlookUserSettings.sh
Created December 10, 2016 17:02
Shell script to change current user's Outlook settings
#!/bin/sh
# get current active console user
shortName=$( /usr/bin/logname )
# AppleScript command to set domain for console user in Outlook
command1="tell application \"Microsoft Outlook\" to set domain of Exchange account 1 to \"domainname\""
# AppleScript command to set user for console user in Outlook
command2="tell application \"Microsoft Outlook\" to set user name of Exchange account 1 to \"$shortName\""
@talkingmoose
talkingmoose / SendMail.sh
Created April 3, 2017 20:45
Send a message via authenticated mail SMTP server such as Hotmail or Google.
#!/bin/sh
# -v = verbose
# -r = From address
# -c = Cc, 'someone@example.com,somebody@example.com'
# -b = Bcc, 'someone@example.com,somebody@example.com'
# -s = Subject
# -S = variable key=value
echo "This is the message body and contains the message" | mailx -v -r talkingmoose@hotmail.com -c "bill.smith@jamf.com" -s "This is the subject" -S smtp="smtp-mail.outlook.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="talkingmoose@hotmail.com" -S smtp-auth-password="P@55w0rd" -S nss-config-dir=/etc/pki/nssdb/ -S HOME=/tmp -S ssl-verify=ignore bill@talkingmoose.net
@talkingmoose
talkingmoose / Reset JSS DEP Enrollment.sh
Last active April 27, 2017 19:45
Add to Self Service and enable only for specific users for testing and resetting DEP enrollments.
#!/bin/sh
sudo rm /var/db/.AppleSetupDone
sudo rm -rf /var/db/ConfigurationProfiles/
sudo rm /Library/Keychains/apsd.keychain
sudo jamf removeFramework
sudo reboot
exit 0
@talkingmoose
talkingmoose / com.apple.Safari.plist
Last active June 3, 2017 15:18
Opens Safari to homepage and all new windows and tabs to homepage.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AlwaysShowFavoritesBarInFullScreen</key>
<false/>
<key>HomePage</key>
<string>http://ahschools.us</string>
<key>NewTabBehavior</key>
<integer>0</integer>
@talkingmoose
talkingmoose / com.google.chrome.plist
Last active June 3, 2017 15:32
Based on management settings: http://www.chromium.org/administrators/policy-list-3 Do not ask to set as default browser Enable pop-up windows Disable autoupdate via web or P2P Sets homepage and new taps to open with homepage Disables prompt to ask to import settings from other browsers Shows home button Disable Welcome window.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DefaultBrowserSettingEnabled</key>
<false/>
<key>DefaultPopupsSetting</key>
<integer>1</integer>
<key>DeviceAutoUpdateDisabled</key>
<true/>
@talkingmoose
talkingmoose / SetARDComputerInformationField.sh
Last active June 9, 2017 14:24
Generic script to set values ARD Info fields 1-4 by passing parameters $4 and $5 (Jamf) or $1 and $2 (Terminal). Useful for scoping in Jamf. Create companion Extension Attribute (using New From Template) to read each field. Defaults to setting ARD Info field 3 to "student".
#!/bin/sh
# use parameters passed to the script
# if no parameters are passed, use default settings
if [ "$4" = "" ] ; then
ardField="3"
else
ardField="$4"
fi