Skip to content

Instantly share code, notes, and snippets.

View matthewbodaly's full-sized avatar

Matthew matthewbodaly

View GitHub Profile
@matthewbodaly
matthewbodaly / ea_check_for_config_profile.sh
Last active November 20, 2016 04:54 — forked from opragel/ea_check_for_config_profile.sh
ea_check_for_config_profile.sh
#!/bin/bash
CONFIGURATION_PROFILE_UUID="43EA456A-C3F4-42F8-B752-E285385D0838"
computerConfigProfiles=$(profiles -Lv | grep "name: $4" -4 | awk -F": " '/attribute: profileIdentifier/{print $NF}')
if [[ "$computerConfigProfiles" == *$CONFIGURATION_PROFILE_UUID* ]]; then
configCheckResult='T'
else
configCheckResult='F'
fi
printf "<result>%s</result>" "$configCheckResult"
@matthewbodaly
matthewbodaly / FindInstalledProfiles.md
Last active August 2, 2022 14:17
Need to find if a profile is installed on a computer? Here's how I did it.

I was having problems deploying a profile to a set of computers. I've observed that occasionally MDM needs to be reset on a computer (thanks Apple / JAMF). About 50% of computers in this set were still showing as "pending" for a specific profile. This is after confirming the computers in the office and I've spammed "send blank push" and have cancelled all pending / failed commands. These computers were still regularly checking in, so that part worked.

Part 1. - Test and Detect -- Deploy SadMDM (or sadderMDM) manually via Self Service to a few affected computers to verify that this works on the network. You can see the commands for SadMDM (there's got to be a better name for this) here: (https://gist.github.com/matthewbodaly/818be381744261a432b4794a410b8bc9) -- Add the EA below to the JSS. This will show all installed profiles as an Extension attribute. -- Make a smart group that has "Is Not Like" the UUID of the profile you are searching for. You could do another thing, but ... UUID is harder to masquerade a

@matthewbodaly
matthewbodaly / removeflash.sh
Created August 31, 2016 21:06
Your FUNERAL
#!/bin/bash
# your funeral
LOCAL_INSTALL_MANAGER="/Applications/Utilities/Adobe Flash Player Install Manager.app/Contents/MacOS/Adobe Flash Player Install Manager"
DOWNLOAD_URL="https://fpdownload.macromedia.com/get/flashplayer/current/support/uninstall_flash_player_osx.dmg"
DMG_NAME=$(printf "%s" "$DOWNLOAD_URL" | sed 's@.*/@@')
LOCAL_DMG_PATH="/tmp/$DMG_NAME"
LOCAL_VOLUME_NAME="Flash Player"
localFlashVersion=$(/usr/bin/defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/version" CFBundleShortVersionString)
@matthewbodaly
matthewbodaly / restartedneeded.sh
Created August 16, 2016 05:35
Ea for figuring out if a restart is needed
#!/bin/bash
# I could probably do it this way with a little time
# https://jamfnation.jamfsoftware.com/discussion.html?id=19323
installAtLogoutItems=$(defaults read /Library/Updates/index.plist InstallAtLogout)
printf '<result>'
if [ ${#installAtLogoutItems} -le 3 ]; then
printf 'No updates pending'
else
printf "%s" "${installAtLogoutItems:1:${#installAtLogoutItems}--2}"
fi
@matthewbodaly
matthewbodaly / swapfvkey.sh
Created August 11, 2016 17:57
swaps keys.
#!/bin/bash
####################################################################################################
#
# Copyright (c) 2013, JAMF Software, LLC. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
@matthewbodaly
matthewbodaly / renamecomputer.sh
Last active June 6, 2019 20:36
Rename a computer
#!/bin/bash
# copied from https://jamfnation.jamfsoftware.com/discussion.html?id=16743
# v 1.1 cleaned up old way of doing things
name=$(osascript -e 'Tell application "System Events" to display dialog "Please enter a name for your computer or select Cancel." default answer ""' -e 'text returned of result' 2>/dev/null)
if [ $? -ne 0 ]
then # user cancel
exit
elif [ -z "$name" ]
then # loop until input or cancel
@matthewbodaly
matthewbodaly / converticons.sh
Created June 30, 2016 15:35
Makes icons. Not mine.
#!/bin/sh
#Tested with 10.7.4 on 6/15/2012
#Written by Kyle Bareis
#This script has no warranty. Use at your own risk!
#######################################################################################
################################### Read this part! ###################################
#######################################################################################
@matthewbodaly
matthewbodaly / jssdependencyinstaller.sh
Last active June 20, 2016 21:36
Quick and dirty dependency installer
#!/bin/sh
# run as sudo
# you probably should google and run "jssinabox" and not this.
add-apt-repository ppa:openjdk-r/ppa
apt-get update
apt-get install openjdk-8-jdk mysql-server
apt-get update
@matthewbodaly
matthewbodaly / autoslack.sh
Created June 3, 2016 21:59
Installs Slack. Thanks Owen.
#!/bin/sh
# Downloads and installs the latest version of Slack for OS X
printf "Slack auto-install script for OS X\n\n"
SLACK_DOWNLOAD_URL="https://slack.com/ssb/download-osx"
SLACK_10_6_DOWNLOAD_URL="https://slack.com/ssb/download-osx-10-6"
SLACK_ZIP_PATH="/tmp/Slack.app.zip"
SLACK_UNZIP_DIRECTORY="/tmp"
@matthewbodaly
matthewbodaly / choices.sh
Created May 23, 2016 20:28
pulled from slack. its an idea.
response=$(curl -H "Accept: application/xml" $jssURL/JSSResource/computerextensionattributes/name/Software%20Status --user $userPass)
choices=$(echo $response | /usr/bin/xpath "//popup_choices/choice/text()" )
removeChoices=$(echo $choices | /usr/bin/awk -F '<choice>|</choice>' '{print $2}')
echo
echo $removeChoices