Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
talkingmoose / Verify App or KExt Notarization.bash
Created October 27, 2019 16:41
Add this to a new Automator Actions item and save as a Service. Right-click or Control-click an app or kext to verify notarization. Optionally, run as a script in Terminal using the path to an app or kext as the first argument.
#!/bin/bash
testFile="$1"
if [[ "$testFile" != *'.app' ]] && [[ "$testFile" != *'.kext' ]] ; then
theCommand='display dialog "This item does not appear to be an application or kernel extension." with title "Verify Notarization" buttons {"OK"} default button {"OK"}'
else
testBinary=$( /usr/bin/stapler validate "$testFile" | /usr/bin/grep '64-bit' )
# per the man page, stapler returns 0 on successful stapling or validation
@talkingmoose
talkingmoose / Catalina-compatible Macs (regex)
Last active November 1, 2021 20:33
Regex looks for all Mac models compatible with Catalina. May not be up-to-date with newly released models.
Model information: https://support.apple.com/en-us/HT210222
Published Date: February 01, 2021
Validation: https://regex101.com/r/p5r9WT/3/
This regex is exact. No new models are supported.
(MacBookAir[5-9]|MacBookPro(9|1[0-6])|MacPro[6-7]|iMac(Pro1|1[3-9]|20)|MacBook(10|9|8)|Macmini[6-8]),\d
pattern matches:
@talkingmoose
talkingmoose / Manage App Notifications.bash
Last active January 25, 2024 15:26
macOS Catalina will prompt users to allow Notifications from each app that makes a request. Administrators can manage these prompts using a Configuration Profile. If running Jamf Pro 10.19 or later, I suggest instead using this manifest: https://github.com/talkingmoose/jamf-manifests/blob/master/macOS%20Notifications%20(com.apple.notificationset…
#!/bin/bash
<<ABOUT_THIS_SCRIPT
-----------------------------------------------------------------------
Written by:William Smith
Professional Services Engineer
Jamf
[email protected]
https://gist.github.com/talkingmoose/9faf50deaaefafa9a147e48ba39bb4b0
@talkingmoose
talkingmoose / List Standard Users.bash
Created September 25, 2019 04:58
Extension attribute for Jamf Pro to list all standard users on a macOS system.
#!/bin/bash
# create user list of all users with UIDs above 500
userList=$( /usr/bin/dscl /Local/Default list /Users uid | /usr/bin/awk '$2 >= 500 { print $1 }' )
# for each user...
for aUser in $userList
do
# check membership of user in admin group
if [[ $( /usr/bin/dsmemberutil checkmembership -U $aUser -G admin | /usr/bin/grep "is not a member of the group" ) ]]; then
@talkingmoose
talkingmoose / Delete Network Segments.bash
Created September 13, 2019 18:50
Deletes all network segments in Jamf Pro containing a specific string.
#!/bin/sh
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Written by: William Smith
# Professional Services Engineer
# Jamf
# [email protected]
#
# Originally posted: September 13, 2019
@talkingmoose
talkingmoose / Upload Jamf Network Segments.bash
Created September 13, 2019 18:33
Creates network segments in Jamf Pro from a supplied CSV file.
#!/bin/sh
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Written by: William Smith
# Professional Services Engineer
# Jamf
# [email protected]
#
# Originally posted: September 13, 2019
@talkingmoose
talkingmoose / com.apple.screensaver.plist.html
Last active June 5, 2020 17:21
Enables or disables System Preferences > Security & Privacy > General > Require password and sets number of seconds to require password after sleep or screen saver begins
<?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>askForPassword</key>
<true/>
<key>askForPasswordDelay</key>
<integer>60</integer>
<key>idleTime</key>
<integer>840</integer>
@talkingmoose
talkingmoose / Mojave-compatible Macs (regex).txt
Last active December 8, 2021 23:47
Regex looks for all Mac models compatible with Mojave. May not be up-to-date with newly released models.
^(MacBookAir[5-8]|MacBookPro[19][0-5]?|1[3-9]|MacPro1|MacPro[56]|MacBook[189][0]?|Macmini[6-8]|iMac1[3-8]|iMacPro.*),.*
or
i?Mac(BookAir[5-8]|BookPro[19][0-5]?|1[3-9]|Pro1|Pro[56]|Book[189][0]?|mini[6-8]),.*
pattern matches:
@talkingmoose
talkingmoose / Office 2019 for Mac versions (regex).txt
Last active August 23, 2019 16:54
Regex strings to identify Office for Mac 2016 and 2019 versions.
version list for testing:
17.0.0
16.99.1
16.90
16.22
16.16.11
16.16.10
16.16.7
16.21.1
@talkingmoose
talkingmoose / osascriptTextandButton.bash
Created July 31, 2019 22:41
Method for returning both text and button from osascript dialog
#!/bin/bash
results=$( /usr/bin/osascript -e "display dialog \"Text and Buttons!\" default answer \"Some text...\" buttons {\"Cancel\",\"OK\"} default button {\"OK\"}" )
theButton=$( echo "$results" | /usr/bin/awk -F "button returned:|," '{print $2}' )
theText=$( echo "$results" | /usr/bin/awk -F "text returned:" '{print $2}' )
echo $theButton
echo $theText