├── .gitattributes ├── .github └── workflows │ └── remove-wfr-tag.yml ├── .gitignore ├── CheckDownloadsFolder.sh ├── LastRestart.sh ├── README.md ├── ResetPrinters.sh ├── dockclean.sh ├── findVPPapps.sh ├── laptopReplacer.sh ├── obsolete ├── .DS_Store ├── CheckWarranty.sh ├── DEP-newcomputer.sh ├── README.md ├── brandSelfService.sh ├── check-chrome-users.sh ├── make-computername-prompt.sh ├── make-computername.sh ├── movecoDi.sh ├── readUSBMACEA.sh ├── rename-computer-CoDi.sh ├── swipely-awdl0-EA.sh ├── swipely-disable-awdl0.sh └── writeUSBMAC.sh ├── setScreensaver.sh ├── sysdiagnoseAssistant.zsh └── uslWatcherUploader.zsh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/remove-wfr-tag.yml: -------------------------------------------------------------------------------- 1 | name: Remove waiting-for-response tag 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | jobs: 8 | remove-tag: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Remove waiting-for-response label if present 12 | uses: actions/github-script@v6 13 | with: 14 | script: | 15 | const issue = context.payload.issue; 16 | if (!issue) { 17 | console.log("No issue or PR found in the payload."); 18 | return; 19 | } 20 | const labels = issue.labels.map(label => label.name); 21 | if (labels.includes("waiting-for-response")) { 22 | console.log(`Removing label 'waiting-for-response' from issue/PR #${issue.number}`); 23 | await github.issues.removeLabel({ 24 | owner: context.repo.owner, 25 | repo: context.repo.repo, 26 | issue_number: issue.number, 27 | name: "waiting-for-response" 28 | }); 29 | } else { 30 | console.log("Label 'waiting-for-response' not found on this issue/PR."); 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /CheckDownloadsFolder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # File Name:CheckDownloadsFolder.sh 4 | # Check and report via EA size of user's Downloads folder 5 | # github.com/acodega 6 | # 7 | 8 | #find logged in user 9 | loggedinuser=$( scutil <<< "show State:/Users/ConsoleUser" | awk -F': ' '/[[:space:]]+Name[[:space:]]:/ { if ( $2 != "loginwindow" ) { print $2 }}' ) 10 | 11 | #find how large downloads is 12 | downloads=$(du -hd 1 /Users/"$loggedinuser"/Downloads | awk 'END{print $1}') 13 | 14 | #echo it for EA 15 | echo "$downloads" 16 | -------------------------------------------------------------------------------- /LastRestart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # File Name:LastRestart.sh 5 | # Extension attribute to check and report the time of the Mac's last startup 6 | # Extension attributes are intended for use with Jamf Pro 7 | # Available at https://github.com/acodega 8 | # 9 | 10 | # Use sysctl kern.boottime to get date and time, then format it as a date attribute for Jamf 11 | echo "$(date -jf "%s" "$(sysctl kern.boottime | awk -F'[= |,]' '{print $6}')" +"%Y-%m-%d %T")" 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jamf Pro Scripts 2 | Scripts and extension attributes I use in Jamf Pro 3 | 4 | February 2022: I am archiving this repository for the time being. In my current line of work I'm not maintaining or publishing Jamf Pro related work. 5 | 6 | November 2024: I am now back in a Jamf Pro role, and unarchiving this repository! Keep in mind right now a lot of content in here is old and likely irrelevant. Hopefully that will change soon. 7 | -------------------------------------------------------------------------------- /ResetPrinters.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #File Name:ResetPrinters.sh 3 | ######################################################################## 4 | # Created By: Jacob Salmela (JAMF Nation) and customized by Adam Codega 5 | # Creation Date: December 2015 6 | # Brief Description: Reset printer system by restoring CUPS to default 7 | # and removing all printers. cocoaDialog is used to interact with the user 8 | ######################################################################## 9 | # 10 | 11 | #Find out where JAMF is because of the JSS 9.8 binary move 12 | jamfbinary='/usr/bin/which jamf' 13 | 14 | # Check for cocoaDialog and if not install it 15 | if [ -d "/Applications/Utilities/cocoaDialog.app" ]; then 16 | echo "CocoaDialog.app installed, continuing on" 17 | else 18 | echo "CocoaDialog.app not found, pausing to install" 19 | $jamfbinary policy -event cocoa 20 | fi 21 | coDi="/Applications/Utilities/cocoaDialog.app/Contents/MacOS/CocoaDialog" 22 | 23 | # Ask user to confirm they want to reset all printers 24 | confirm=`$coDi msgbox --float --title "Resetting Printers" --icon x --height 150 --text "Are you sure you want to remove all printers?" --informative-text "You will need to reinstall them from Self Service" --button1 "Yes" --button2 "No" --button3 "Cancel"` 25 | 26 | # Check result of confirm 27 | if [ "$confirm" == "1" ]; then 28 | echo "User confirmed, continuing.." 29 | elif [ "$confirm" == "2" ]; then 30 | echo "User did not confirm, exiting.." 31 | exit 0 32 | elif [ "$confirm" == "3" ]; then 33 | echo "User canceled, exiting.." 34 | exit 0 35 | fi 36 | 37 | # Stop CUPS 38 | echo "launchctl stop org.cups.cupsd" 39 | 40 | # Remove CUPS config file 41 | echo "rm /etc/cups/cupsd.conf" 42 | 43 | # Restore the default config by copying it 44 | echo "cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf" 45 | 46 | # Remove the printers 47 | echo "rm /etc/cups/printers.conf" 48 | 49 | # Start CUPS again 50 | echo "launchctl start org.cups.cupsd" 51 | -------------------------------------------------------------------------------- /dockclean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure the dock for a new user 4 | 5 | DOCKUTIL=/usr/local/bin/dockutil 6 | 7 | $DOCKUTIL --remove all --no-restart 8 | 9 | $DOCKUTIL --add '/Applications/Launchpad.app' --no-restart 10 | 11 | $DOCKUTIL --add '/Applications/Google Chrome.app' --no-restart 12 | 13 | $DOCKUTIL --add '/Applications/System Preferences.app' --no-restart 14 | 15 | $DOCKUTIL --add '~/Downloads' 16 | 17 | sleep 2 18 | 19 | /usr/bin/killall Dock >/dev/null 2>&1 20 | 21 | exit 0 -------------------------------------------------------------------------------- /findVPPapps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # JAMF Extension Attribute that finds any MAS apps 4 | # that were purchased through VPP and which account 5 | # purchased it. 6 | # Crafted by Craig Lindsey for Starz 2017-2-10 7 | # 8 | 9 | mdfind -onlyin /Applications/ 'kMDItemAppStoreReceiptIsVPPLicensed == "1"' | while read VPPApp; do 10 | AppOwner=$( mdls "$VPPApp" -name kMDItemAppStoreReceiptOrganizationDisplayName | awk '{ print $3, $4 }' | sed -e 's/^\"//' -e 's/"$//' ) 11 | AppName=$( echo "$VPPApp" | awk -F'/' '{print $NF}' | sed -e 's/^"//' -e 's/"$//') 12 | result="$AppName $AppOwner" 13 | 14 | echo "$result" 15 | done 16 | -------------------------------------------------------------------------------- /laptopReplacer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script will show to the user when their laptop is due for replacement 4 | # by estimating its estimated manufacturer date and adding two years to that date. 5 | # 6 | # We'll display the info to the user using cocoaDialog. 7 | # 8 | # Warranty estimator via https://github.com/chilcote/warranty 9 | # 10 | # Update lines 15 and 16 for your organization 11 | # 12 | # Adam Codega, Upserve 13 | # 14 | 15 | coDi="/Applications/Utilities/cocoaDialog.app/Contents/MacOS/CocoaDialog" 16 | borndate=`/Library/Application\ Support/Upserve/warranty-check/warranty | awk '/Manufactured/ {print $3}'` 17 | deathdate=`date -j -f %Y-%m-%d -v+2y $borndate +"%b %d, %Y"` 18 | 19 | $coDi ok-msgbox --no-cancel --title "Laptop Replacement Check" --text "Your laptop warranty expires on or around $deathdate" --informative-text "Your laptop replacement will be scheduled near that date" --icon computer &> /dev/null 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /obsolete/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acodega/jamfProScripts/ec71404dbcd1ca618233afff03fda9d956df28f7/obsolete/.DS_Store -------------------------------------------------------------------------------- /obsolete/CheckWarranty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #File Name:CheckWarranty.sh 3 | ######################################################################## 4 | # Created By: Andrew Tomson Modified by Ross Derewianko for Self Service 5 | # Creation Date: Sept 2015 6 | # Last modified: Sept 28, 2015 7 | # Brief Description: Lets the user Know its changed 8 | ######################################################################## 9 | # this script was written to query apple's service database to determine warranty coverage 10 | # base on a system's serial number. This updated version stores the information locally so 11 | # as not to have to query apple's website repeatedly. 12 | 13 | #Find out where JAMF is 14 | jamfbinary=`/usr/bin/which jamf` 15 | 16 | #check for cocoaDialog and if not install it 17 | if [ -d "/Applications/Utilities/cocoaDialog.app" ]; then 18 | echo "CocoaDialog.app installed, continuing on" 19 | else 20 | $jamf_binary policy -trigger cocoa 21 | echo "CocoaDialog.app not found, pausing to install" 22 | fi 23 | coDi="/Applications/Utilities/cocoaDialog.app/Contents/MacOS/CocoaDialog" 24 | 25 | 26 | if [ -f /Library/Preferences/com.apple.warranty.plist ]; then 27 | # get plist data 28 | WarrantyDate=`/usr/bin/defaults read /Library/Preferences/com.apple.warranty WarrantyDate` 29 | WarrantyStatus=`/usr/bin/defaults read /Library/Preferences/com.apple.warranty WarrantyStatus` 30 | 31 | # convert dates to integers 32 | ExpirationDate=`/bin/date -j -f "%Y-%m-%d" "${WarrantyDate}" +%s` 33 | TodaysDate=`/bin/date +%s` 34 | 35 | # if warranty is listed as active but date is expired, update plist entry 36 | if [ "${WarrantyStatus}" == "Active" ] && [ ${TodaysDate} -gt ${ExpirationDate} ]; then 37 | WarrantyStatus="Inactive" 38 | /usr/bin/defaults write /Library/Preferences/com.apple.warranty WarrantyStatus ${WarrantyStatus} 39 | echo Status updated. 40 | else 41 | echo Status unchanged. 42 | fi 43 | echo "${WarrantyStatus} : ${WarrantyDate}" 44 | fi 45 | 46 | 47 | # set temp file 48 | WarrantyTempFile="/tmp/warranty.$(date +%s).txt" 49 | 50 | 51 | # get serial number 52 | SerialNumber=`ioreg -l | awk '/IOPlatformSerialNumber/ { split($0, line, "\""); printf("%s\n", line[4]); }'` 53 | if [ -z "${SerialNumber}" ]; then 54 | echo "Serial Number not found." 55 | exit 1 56 | fi 57 | 58 | 59 | # query url 60 | WarrantyURL="https://selfsolve.apple.com/wcResults.do?sn=${SerialNumber}&Continue=Continue&num=0" 61 | WarrantyInfo=$(curl -k -s $WarrantyURL | awk '{gsub(/\",\"/,"\n");print}' | awk '{gsub(/\":\"/,":");print}' | sed s/\"\}\)// > ${WarrantyTempFile}) 62 | 63 | 64 | # check validity of serial number 65 | InvalidSerial=$(grep 'invalidserialnumber\|productdoesnotexist' "${WarrantyTempFile}") 66 | if [[ -n "${InvalidSerial}" ]]; then 67 | echo "Invalid Serial Number." 68 | exit 2 69 | fi 70 | 71 | 72 | # determine warranty status 73 | WarrantyStatus=$(grep displayHWSupportInfo "${WarrantyTempFile}") 74 | if [[ $WarrantyStatus =~ "Active" ]]; then 75 | WarrantyStatus="Active" 76 | else 77 | WarrantyStatus="Inactive" 78 | fi 79 | 80 | 81 | # check for expiration date 82 | if [[ `grep displayHWSupportInfo "${WarrantyTempFile}"` ]]; then 83 | WarrantyDate=`grep displayHWSupportInfo "${WarrantyTempFile}" | grep -i "Estimated Expiration Date:"| awk -F'
' '{print $2}'|awk '{print $4,$5,$6}'` 84 | fi 85 | 86 | 87 | # convert format of date 88 | if [[ -n "$WarrantyDate" ]]; then 89 | WarrantyDate=$(/bin/date -jf "%B %d, %Y" "${WarrantyDate}" +"%Y-%m-%d") > /dev/null 2>&1 90 | else 91 | WarrantyDate="N/A" 92 | fi 93 | 94 | 95 | # write status and date to plist 96 | if [[ -n "$WarrantyStatus" ]] && [[ -n "$WarrantyDate" ]]; then 97 | /usr/bin/defaults write /Library/Preferences/com.apple.warranty WarrantyStatus ${WarrantyStatus} 98 | /usr/bin/defaults write /Library/Preferences/com.apple.warranty WarrantyDate ${WarrantyDate} 99 | fi 100 | 101 | #--- debug lines-- 102 | #echo Serial Number: "${SerialNumber}" 103 | #echo Warranty Status: ${WarrantyStatus} 104 | #echo Warranty Expiration: ${WarrantyDate} 105 | #---/debug--- 106 | #lets pop this info up to the user 107 | "$coDi" ok-msgbox --title "Your Warranty Expires" --text "Warranty info" --informative-text "Serial Number: ${SerialNumber} 108 | Warranty Status: ${WarrantyStatus} 109 | Warranty Expiration: ${WarrantyDate}" --no-cancel --icon info 110 | exit 0 111 | 112 | 113 | -------------------------------------------------------------------------------- /obsolete/DEP-newcomputer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | ######################################################################## 4 | # Created By: Adam Codega, Swipely Inc. 5 | # with help from Ross Derewianko Ping Identity Corporation 6 | # Creation Date: June 2015 7 | # Last updated: Dec 2015 8 | # Brief Description: Changes machine hostname based on first initial and 9 | # last name of local user. Then, ask IT tech which department to 10 | # set computer to in JSS. Follows up with installing updates, 11 | # running a recon, and telling tech it's ready to restart. 12 | ######################################################################## 13 | 14 | ######################################################################## 15 | # Lets locate some Applications 16 | ######################################################################## 17 | 18 | #Find out where JAMF is because of the JSS 9.8 binary move 19 | jamfbinary='/usr/bin/which jamf' 20 | 21 | #check for cocoaDialog and if not install it 22 | if [ -d "/Applications/Utilities/cocoaDialog.app" ]; then 23 | echo "CocoaDialog.app installed, continuing on" 24 | else 25 | echo "CocoaDialog.app not found, pausing to install" 26 | $jamfbinary policy -event cocoa 27 | fi 28 | coDi="/Applications/Utilities/cocoaDialog.app/Contents/MacOS/CocoaDialog" 29 | 30 | #check for Dockutil and if not install it 31 | if [ -f "/usr/local/bin/dockutil" ]; then 32 | echo "Dockutil.app installed, continuing on" 33 | else 34 | echo "Dockutil not found, pausing to install" 35 | $jamfbinary policy -event dockutil 36 | fi 37 | dockutil="/usr/local/bin/dockutil" 38 | 39 | ####################################################################### 40 | # Figure out the hostname 41 | ####################################################################### 42 | 43 | #Set the hostname 44 | 45 | # figure out the user 46 | user=$(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");') 47 | 48 | #figure out the user's full name 49 | name=$(finger "$user" | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //' ) 50 | 51 | # get first initial 52 | finitial="$(echo "$name" | head -c 1)" 53 | 54 | # get last name 55 | ln="$(echo "$name" | cut -d \ -f 2)" 56 | 57 | # add first and last together 58 | un=($finitial$ln) 59 | 60 | # clean up un to have all lower case 61 | hostname=$(echo "$un" | awk '{print tolower($0)}') 62 | 63 | ####################################################################### 64 | # Clean up the dock 65 | ####################################################################### 66 | 67 | $dockutil --remove all 68 | $dockutil --add '/Applications/Launchpad.app' --no-restart 69 | $dockutil --add '/Applications/System Preferences.app' --no-restart 70 | $dockutil --add "/$HOME/Downloads" 71 | 72 | ####################################################################### 73 | # Functions 74 | ####################################################################### 75 | 76 | sethostname() { 77 | $jamfbinary setComputerName -name "$hostname" 78 | } 79 | 80 | cdprompt() { 81 | jssdept=$("$coDi" standard-dropdown --string-output --title "Choose a Department" --height 150 --text "Department" --items "Business Administration" Technology Finance Marketing Product Sales Success Talent) 82 | 83 | if [ "$jssdept" == "2" ]; then 84 | echo "user cancelled" 85 | exit 1 86 | fi 87 | cleanjssdept 88 | } 89 | 90 | #cleans the first two characters out (cocoaDialog adds a 1 \n to the string value which we don't need.) 91 | cleanjssdept() { 92 | dept=$(echo "$jssdept" | sed -n 2p) 93 | } 94 | 95 | #sets department using JAMF Framework Recon command 96 | setdepartment() { 97 | $jamfbinary recon -department "$dept" 98 | } 99 | 100 | 101 | ######################################################################## 102 | # Script 103 | ######################################################################## 104 | 105 | # sometimes we image (don't tell anyone) so we need to makes sure Site is Upserve and Department is None 106 | $jamfbinary recon -building "Upserve" 107 | $jamfbinary recon -department "None" 108 | 109 | sethostname 110 | cdprompt 111 | setdepartment 112 | 113 | # now that the dept is set let's apply profiles and policies 114 | $jamfbinary manage 115 | $jamfbinary policy 116 | 117 | # manage and policy probably changed stuff, so let's submit an updated inventory 118 | $jamfbinary recon 119 | 120 | # set softwareupdate schedule On 121 | softwareupdate --schedule on 122 | 123 | # install all updates with verbose output 124 | softwareupdate -via 125 | 126 | # recon again 127 | $jamfbinary recon 128 | 129 | #notify the tech that computer is ready for restart 130 | $coDi bubble --no-timeout --title "Upserve Enrollment Complete" --text "Restart to enable FileVault 2 Encryption" --icon "computer" 131 | -------------------------------------------------------------------------------- /obsolete/README.md: -------------------------------------------------------------------------------- 1 | # Jamf Pro, obsolete things 2 | These are scripts and extension attributes I've used in the past with Jamf Pro but they are considered obsolete or simply not applicable to modern macOS. 3 | -------------------------------------------------------------------------------- /obsolete/brandSelfService.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # brandSelfService.sh 4 | # 5 | # Copy pre-made graphic files inside 6 | # of Self Service.app for branding purposes 7 | # 8 | # HOW TO: 9 | # 1: Download Self Service from your JSS (SelfService.tar.gz) 10 | # 11 | # 2: Place this script and SelfService.tar.gz in a folder 12 | # chmod +x this script 13 | # Place assets (see Files Needed below) in a subfolder named icons 14 | # 15 | # 3: Run ./brandSelfService.sh from Terminal 16 | # 17 | # Files Needed: 18 | # Your replacement icon for the app, 256x256: /icons/appicon.icns 19 | # Your Retina replacement icon for the app, 512x512: /icons/appicon@2x.icns 20 | # Your replacement for the status area of SS, 84x84: /icons/logo-SelfService.tiff 21 | # 22 | # YOU MUST RUN THIS COMMAND WITH ELEVATED PRIVILEGES (sudo) 23 | # 24 | # For use with the JAMF Casper Suite 25 | # 26 | # Adam Codega, Swipely 27 | # 28 | 29 | # Unzip SelfService.tar.gz 30 | tar -zxvf SelfService.tar.gz 31 | 32 | # Clear the quarantine from Self Service.app 33 | xattr -r -d com.apple.quarantine Self\ Service.app 34 | 35 | # Copy the icon into place 36 | echo "Copying the icon file into place.." 37 | cp icons/appicon.icns Self\ Service.app/Contents/Resources/Self\ Service.icns 38 | chmod 744 Self\ Service.app/Contents/Resources/Self\ Service.icns 39 | 40 | # Copy the Retina icon into place 41 | echo "Copying the Retina icon into place.." 42 | cp icons/appicon@2x.icns Self\ Service.app/Contents/Resources/Self\ Service@2x.icns 43 | chmod 744 Self\ Service.app/Contents/Resources/Self\ Service.icns 44 | 45 | # Copy the status area icon into place 46 | echo "Copying the status area icon into place.." 47 | cp icons/logo-SelfService.tiff Self\ Service.app/Contents/Resources/jsLogo-SelfService.tiff 48 | chmod 744 Self\ Service.app/Contents/Resources/Self\ Service.icns 49 | 50 | # Rename Self Service in it's plist 51 | echo "Renaming Self Service in info.plist and chmoding it.." 52 | # Put your preferred app name at the end of this line in double quotes 53 | defaults write Self\ Service.app/Contents/Info CFBundleName "Swipely Service" 54 | chmod 744 Self\ Service.app/Contents/Info.plist 55 | 56 | # Rename the app itself 57 | echo "Renaming Self Service the app itself.." 58 | # Put your preferred app name at the end of the next line in double quotes 59 | mv Self\ Service.app "Swipely Service.app" 60 | 61 | echo 62 | echo "Done. You've been branded." 63 | echo 64 | -------------------------------------------------------------------------------- /obsolete/check-chrome-users.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # check-chrome-users.sh 4 | # 5 | # Extension attribute to report which accounts 6 | # are logged into Google Chrome on a Mac. 7 | # 8 | # For use as a JAMF Casper Suite extension attribute 9 | # 10 | # Adam Codega, Swipely 11 | # 12 | 13 | loggedinuser=`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");'` 14 | 15 | chromestate=`cat /Users/$loggedinuser/Library/Application\ Support/Google/Chrome/Local\ State | python -m json.tool | grep user_name` 16 | 17 | echo "$chromestate" 18 | -------------------------------------------------------------------------------- /obsolete/make-computername-prompt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Let's name this computer based off the user who's logged in right now. 4 | # We'll display the name to the user and let them change it. 5 | 6 | # find the JAMF binary location 7 | jamfbinary=$(/usr/bin/which jamf) 8 | 9 | # find the user who's logged in 10 | currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk -F': ' '/[[:space:]]+Name[[:space:]]:/ { if ( $2 != "loginwindow" ) { print $2 }}' ) 11 | 12 | # get full name 13 | name=$(finger "$user" | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //' ) 14 | 15 | # get first name initial 16 | finitial="$(echo "$name" | head -c 1)" 17 | echo "$finitial" 18 | 19 | # get lastname 20 | ln="$(echo "$name" | cut -d \ -f 2)" 21 | echo "$ln" 22 | 23 | # add first and last together 24 | fullname=($finitial$ln) 25 | 26 | # clean up fullname to lower case 27 | hostname=$(echo "$fullname" | awk '{print tolower($0)}') 28 | 29 | # prompt user to name computer with hostname prefilled and capture it 30 | prompt=$(sudo -u $currentUser osascript -e 'display dialog "Enter computer name:" default answer "'$hostname'"') 31 | 32 | # get the user's input from the prompt variable. We should sanitize this in case they inserted spaces. But we're not. 33 | theName=$( echo "$prompt" | /usr/bin/awk -F "text returned:" '{print $2}' ) 34 | 35 | # check if theName is was entered empty, and set the hostname to what we want. I don't think this is the best way to do this though. 36 | if [ -z "$theName" ] 37 | then $jamfbinary setComputerName -name "$hostname" 38 | else $jamfbinary setComputerName -name "$theName" 39 | fi 40 | -------------------------------------------------------------------------------- /obsolete/make-computername.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # make-computername.sh 4 | # 5 | # Get computer user's full name 6 | # And make a firstinitiallastname hostname 7 | # To set the computer name 8 | # 9 | # Adam Codega 10 | # 11 | 12 | # find the JAMF binary location 13 | jamfbinary=$(/usr/bin/which jamf) 14 | 15 | # find the user who's logged in 16 | user=$( scutil <<< "show State:/Users/ConsoleUser" | awk -F': ' '/[[:space:]]+Name[[:space:]]:/ { if ( $2 != "loginwindow" ) { print $2 }}' ) 17 | 18 | # get full name 19 | name=$(finger "$user" | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //' ) 20 | 21 | # get first name 22 | finitial="$(echo "$name" | head -c 1)" 23 | echo "$finitial" 24 | 25 | # clean for lastname 26 | ln="$(echo "$name" | cut -d \ -f 2)" 27 | echo "$ln" 28 | 29 | # add first and last together 30 | fullname=($finitial$ln) 31 | 32 | # clean up fullname to lower case 33 | hostname=$(echo "$fullname" | awk '{print tolower($0)}') 34 | 35 | # name the computer 36 | $jamfbinary setComputerName -name "$hostname" 37 | -------------------------------------------------------------------------------- /obsolete/movecoDi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | ##### 4 | # Created By: Adam Codega, Swipely Inc. 5 | # Creation Date: October 2016 6 | # Brief Description: Check if cocoaDialog and dockutil exists at /usr/sbin and move 7 | # to /Applications/Utilities, for OS X 10.11 support. 8 | ##### 9 | 10 | if [ -d "/usr/sbin/cocoaDialog.app" ]; then 11 | mv /usr/sbin/cocoaDialog.app /Applications/Utilities/cocoaDialog.app 12 | else 13 | echo "CocoaDialog.app not found." 14 | fi 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /obsolete/readUSBMACEA.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Extension attribute to use with writeUSBMAC.sh (which is run when the computer is deployed) 4 | # Read the MAC address of the computer's assigned Belkin USB adapter which has already been stored locally 5 | # Works in macOS Mojave 10.14 6 | 7 | USBMAC=$(defaults read /Library/Preferences/org.vandelay.network.plist Belkin) 8 | 9 | if [[ "$USBMAC" == "" ]]; then 10 | echo "Value has not been set" 11 | else 12 | echo "$USBMAC" 13 | fi 14 | -------------------------------------------------------------------------------- /obsolete/rename-computer-CoDi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ######################################################################## 3 | # Created By: Ross Derewianko Ping Identity Corporation 4 | # Creation Date: Febuary, 2015 5 | # Last modified: Febuary 27, 2015 6 | # Modified for Swipely: May 21st, 2015 Adam Codega 7 | # Brief Description: Changes machine hostname 8 | ######################################################################## 9 | 10 | #check for CocoaDialog & if not install it 11 | 12 | if [ -d "/usr/sbin/cocoaDialog.app" ]; then 13 | CoDi="/usr/sbin/cocoaDialog.app/Contents/MacOS/cocoaDialog" 14 | else 15 | echo "CocoaDialog.app not found installing" 16 | /usr/sbin/jamf policy -trigger cocoa 17 | fi 18 | 19 | ######################################################################## 20 | # Functions 21 | ####################################################################### 22 | 23 | #asks for the new hostname & then call in the cleaner! 24 | 25 | function cdprompt() { 26 | hostname=`"$CoDi" standard-inputbox --title "Rename Computer" --informative-text "Enter new computer name"` 27 | 28 | if [ "$hostname" == "2" ]; then 29 | echo "user cancelled" 30 | exit 1 31 | fi 32 | cleanhostname 33 | } 34 | 35 | #cleans the first two characters out (cocoaDialog adds a 1 \n to the string value which we don't need.) 36 | 37 | function cleanhostname() { 38 | hostname=${hostname:2} 39 | } 40 | 41 | #checks for a blank hostname, and if its blank prompt agian 42 | 43 | function checkforblank() { 44 | while [[ -z $hostname && {$hostname+1} ]] 45 | do 46 | cdprompt 47 | done 48 | } 49 | 50 | function sethostname() { 51 | scutil --set HostName $hostname 52 | scutil --set ComputerName $hostname 53 | scutil --set LocalHostName $hostname 54 | } 55 | 56 | ######################################################################## 57 | # Script 58 | ######################################################################## 59 | 60 | cdprompt 61 | checkforblank 62 | sethostname -------------------------------------------------------------------------------- /obsolete/swipely-awdl0-EA.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # swipely-awdl0-EA.sh 4 | # 5 | # Check if awdl0 interface is active, for use as an extension attribute. 6 | # 7 | # awdl0 has been documented to cause Wi-Fi issues on OS X Yosemite 10.10-10.10.2 8 | # 9 | # https://medium.com/@mariociabarra/wifried-ios-8-wifi-performance-issues-3029a164ce94 10 | # 11 | # Adam Codega, Swipely 12 | # 13 | 14 | echo "$(ifconfig awdl0 | awk '/status/{print $2}')" -------------------------------------------------------------------------------- /obsolete/swipely-disable-awdl0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # swipely-disable-awdl0.sh 4 | # 5 | # Check if awdl0 interface is active, 6 | # if it is, then disable it. 7 | # 8 | # awdl0 has been documented to cause Wi-Fi issues on OS X Yosemite 10.10-10.10.2 9 | # 10 | # This script can run at startup using a JSS policy and "User login" as trigger 11 | # 12 | # (Or launchd/offset if that's your thing.) 13 | # 14 | # https://medium.com/@mariociabarra/wifried-ios-8-wifi-performance-issues-3029a164ce94 15 | # 16 | # Adam Codega, Swipely 17 | # 18 | 19 | # set awdl0 status as a variable 20 | 21 | awdlstatus=$(ifconfig awdl0 | awk '/status/{print $2}') 22 | 23 | # find out if awdl0 is already inactive, if it is, end script. If it's not, disable it. 24 | 25 | if [ "$awdlstatus" = "inactive" ]; then 26 | end 27 | else 28 | ifconfig awdl0 down 29 | fi -------------------------------------------------------------------------------- /obsolete/writeUSBMAC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get the MAC address of the computer's assigned Belkin USB adapter and write it locally 4 | # Helpful when you want to know the MAC address of the adapter being used at the time this script is run 5 | # To be paired with a Jamf Extension Attribute to report this MAC address 6 | # Works in macOS Mojave 10.14 7 | 8 | USBMAC=$(networksetup -listallhardwareports | awk '/Hardware Port: Belkin USB-C LAN/{getline; getline; print $NF}') 9 | 10 | if [[ "$USBMAC" == "" ]]; then 11 | defaults write /Library/Preferences/org.vandelay.network.plist Belkin -string "N/A" 12 | else 13 | defaults write /Library/Preferences/org.vandelay.network.plist Belkin -string "$USBMAC" 14 | fi 15 | -------------------------------------------------------------------------------- /setScreensaver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Set the screen saver time, password delay, and ask for 4 | # password preference for the logged in user. 5 | # 6 | # Adam Codega 7 | # 8 | 9 | loggedinuser=`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");'` 10 | 11 | sudo -u "$loggedinuser" -i defaults -currentHost write com.apple.screensaver idleTime -int 600 12 | 13 | sudo -u "$loggedinuser" -i defaults -currentHost write com.apple.screensaver askForPassword -int 1 14 | 15 | sudo -u "$loggedinuser" -i defaults -currentHost write com.apple.screensaver askForPasswordDelay -int 0 16 | -------------------------------------------------------------------------------- /sysdiagnoseAssistant.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh --no-rcs 2 | # shellcheck shell=bash 3 | # set -x 4 | 5 | # 6 | 7 | dialogApp='/usr/local/bin/dialog' 8 | dialogCommandFile=$(mktemp /var/tmp/exampleDialog.XXXXX) 9 | serialNumber=$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}') 10 | currentUser=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }') 11 | uid=$(id -u "$currentUser") 12 | errorCode=0 13 | 14 | # This function sends a command to our command file, and sleeps briefly to avoid race conditions 15 | function dialogCommand() { 16 | /bin/echo "$@" >> "$dialogCommandFile" 17 | sleep 0.1 18 | } 19 | 20 | # Run as user function, as always 21 | runAsUser() { 22 | if [ "$currentUser" != "loginwindow" ]; then 23 | launchctl asuser "$uid" sudo -u "$currentUser" "$@" 24 | else 25 | printLog "No user logged in" 26 | exit 1 27 | fi 28 | } 29 | 30 | # Calling our initial dialog window. The & is crucial so that our script progresses. 31 | $dialogApp \ 32 | --title "Sysdiagnose Assistant" \ 33 | --message "Preparing to run.." \ 34 | --ontop \ 35 | --moveable \ 36 | --button1disabled \ 37 | --commandfile "$dialogCommandFile" \ 38 | --progress 5 \ 39 | --icon "SF=bolt.circle color1=pink color2=blue" \ 40 | & 41 | 42 | # Pause for effect 43 | sleep 2 44 | 45 | dialogCommand "progress: increment" 46 | dialogCommand "message: Creating directory to store sysdiagnose.." 47 | date=$(date +%Y_%m_%dT%H%M%S) 48 | resultsDirectory=$(mktemp -d /Users/Shared/sysdiagnose-XX-"${date}") 49 | sysdiagnoseName="sysdiagnose-${serialNumber}-${date}.tar.gz" 50 | chmod 755 "${resultsDirectory}" 51 | sleep 1 52 | 53 | dialogCommand "progress: increment" 54 | dialogCommand "message: Running sysdiagnose. This may take 5 minutes.." 55 | sleep 1 56 | /usr/bin/sysdiagnose -f "${resultsDirectory}" -A "$sysdiagnoseName" -u 57 | 58 | dialogCommand "progress: increment" 59 | dialogCommand "Checking if sysdiagnose was created.." 60 | sleep 1 61 | if [[ -f "$resultsDirectory/$sysdiagnoseName" ]]; then 62 | chmod 755 "$resultsDirectory/$sysdiagnoseName" 63 | dialogCommand "progress: increment" 64 | dialogCommand "message: Sysdiagnose successfully created.." 65 | sleep 1 66 | else 67 | dialogCommand "progress: complete" 68 | dialogCommand "message: Sysdiagnose file not created. Please try again our contact the [yourorg] Apple team." 69 | errorCode=1 70 | dialogCommand "button1: enable" 71 | exit $errorCode 72 | fi 73 | 74 | dialogCommand "progress: complete" 75 | dialogCommand "message: Sysdiagnose collection complete. \n\nSysdiagnose stored at $resultsDirectory/$sysdiagnoseName \n\nPlease send this file to the [yourorg] Apple team." 76 | dialogCommand "button1: enable" 77 | 78 | runAsUser open -R "$resultsDirectory/$sysdiagnoseName" 79 | 80 | exit $errorCode 81 | 82 | # Close our dialog window 83 | # dialogCommand "quit:" 84 | 85 | # Delete our command file 86 | # rm "$dialogCommandFile" 87 | -------------------------------------------------------------------------------- /uslWatcherUploader.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh --no-rcs 2 | # shellcheck shell=bash 3 | # set -x 4 | 5 | # Name: uslWatcherUploader.zsh 6 | # v0.3 7 | # In my Jamf repo cause you can have Jamf run this regularly. 8 | 9 | serialNumber=$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}') 10 | orgScriptName="uslWatcherUploader" 11 | orgFQDN="com.contoso" 12 | scriptVersion=0.3 13 | scriptLog=$(mktemp /var/logs/$orgFQDN.$orgScriptName-XXX) 14 | date=$(date +%Y_%m_%dT%H%M%S) 15 | syslogFile="sysdiagnose-${serialNumber}-${date}.logarchive" 16 | log="/usr/bin/log" 17 | errorCode=0 18 | chmod 644 "$scriptLog" 19 | 20 | logger() { 21 | echo -e "${orgScriptName} v($scriptVersion): $(date +%Y-%m-%d\ %H:%M:%S) - ${1}" | tee -a "${scriptLog}" 22 | } 23 | 24 | uploader() { 25 | logger "Making results directory.." 26 | date=$(date +%Y_%m_%dT%H%M%S) 27 | resultsDirectory=$(mktemp -d /Users/Shared/sysdiagnose-"${date}") 28 | sysdiagnoseName="sysdiagnose-${serialNumber}-${date}.tar.gz" 29 | chmod 755 "${resultsDirectory}" 30 | 31 | logger "Made directory $resultsDirectory\$sysdiagnoseName. This may take 5 minutes.." 32 | /usr/bin/sysdiagnose -f "${resultsDirectory}" -A "$sysdiagnoseName" -u > /dev/null 33 | 34 | logger "Checking if sysdiagnose was created.." 35 | if [[ -f "$resultsDirectory/$sysdiagnoseName" ]]; then 36 | chmod 755 "$resultsDirectory/$sysdiagnoseName" 37 | logger "Sysdiagnose successfully created.." 38 | else 39 | logger "Sysdiagnose file was not created. Exiting.." 40 | errorCode=1 41 | fi 42 | 43 | logger "Sysdiagnose collection complete. It is stored at $resultsDirectory/$sysdiagnoseName" 44 | logger "Now FTPing to storage (ftp.contoso.com/$sysdiagnoseName)" 45 | 46 | #pretend it's 2005 and FTP servers are still relevant. Obviously this is where you'd do something like upload to S3, SMB, etc 47 | if ! curl -s -T "$resultsDirectory"/"$sysdiagnoseName" -u user:pass ftp://ftp.contoso.com/; then 48 | logger "Something went wrong with the FTP upload. Exiting.." 49 | errorCode=1 50 | else 51 | logger "FTP upload successful" 52 | fi 53 | } 54 | 55 | logOptions=( 56 | collect 57 | --output /Users/Shared/"$syslogFile" 58 | --last 1d 59 | ) 60 | 61 | logger "Logging to $scriptLog" 62 | logger "My generated log bundle is here $syslogFile" 63 | logger "Collecting the log now..." 64 | $log "${logOptions[@]}" 65 | logger "Checking the log for errors.." 66 | $log show /Users/Shared/"$syslogFile" --predicate 'processImagePath CONTAINS[c] "kernel" && eventMessage CONTAINS[c] "AppleUSBRequest::complete"' &> "/Users/Shared/cat_$syslogFile.txt" 2>&1 67 | 68 | if grep -q "AppleUSBRequest::complete" "/Users/Shared/cat_$syslogFile.txt"; then 69 | logger "Found the search phrase in /Users/Shared/cat_$syslogFile.txt" 70 | # change uploader function to what you want, S3 upload etc. 71 | uploader 72 | rm /Users/Shared/"$syslogFile" 73 | rm /Users/Shared/cat_"$syslogFile".txt 74 | # exit 1 seems odd but you may want the script to exit with an error if it's *found*, so that your MDM alerts you of the "error" 75 | errorCode=1 76 | else 77 | logger "Did not find the search phrase in /Users/Shared/cat_$syslogFile.txt" 78 | fi 79 | 80 | rm -f /Users/Shared/"$syslogFile" 81 | rm /Users/Shared/cat_"$syslogFile".txt 82 | 83 | logger "---------------------------------" 84 | logger "Done" 85 | exit $errorCode 86 | --------------------------------------------------------------------------------