Skip to content

Instantly share code, notes, and snippets.

View smashism's full-sized avatar
:shipit:
ship it!

emily smashism

:shipit:
ship it!
View GitHub Profile
@smashism
smashism / unmanage-devices-modern-auth.sh
Created April 4, 2024 16:04
Programmatically unmanage mobile devices via Jamf Pro API using bearer-auth token authentication.
#!/bin/bash
##########
# title: unmanage-devices-modern-auth.sh
# author: dr. k | @smashism on github
# date: 2024-03-28
# note: include jssIDs where specified, other server/cred details will
# prompt when run via terminal.app
# disclaimer: provided as-is with no warranty (express or implied). please test!
#
@smashism
smashism / unmanage-computers-modern-auth.sh
Last active April 4, 2024 16:03
Programmatically unmanage computers via Jamf Pro API using bearer-auth token authentication.
#!/bin/bash
##########
# title: unmanage-computers-modern-auth.sh
# author: dr. k | @smashism on github
# date: 2024-03-28
# note: include jssIDs where specified, other server/cred details will
# prompt when run via terminal.app
# disclaimer: provided as-is with no warranty (express or implied). please test!
#
@smashism
smashism / unmanage-mobile-devices.sh
Last active July 31, 2023 18:51
Automate marking mobile devices as unmanaged with the Jamf Pro Classic API
#!/bin/bash -x
deviceIDs=(
# put jssIDs here for mobile devices to remove
# ex. 12345678
0000
)
for id in "${deviceIDs[@]}"; do
/usr/bin/curl -sku "apiuser":"apipass" -X PUT -H "content-type: text/xml" "https://yourjamfpro.jamfcloud.com/JSSResource/mobiledevices/id/{$id}" -d "<mobile_device><general><managed>false</managed></general></mobile_device>"
@smashism
smashism / unmanage-computers.sh
Created July 31, 2023 18:49
Automate marking computers as unmanaged with the Jamf Pro Classic API
#!/bin/bash -x
deviceIDs=(
# put jssIDs here for computers to remove
# ex. 12345678
0000
)
for id in "${deviceIDs[@]}"; do
/usr/bin/curl -sku "apiuser":"apipass" -X PUT -H "content-type: text/xml" "https://yourjamfpro.jamfcloud.com/JSSResource/computers/id/{$id}" -d "<computer><general><remote_management><managed>false</managed></remote_management></general></computer>"
#!/bin/bash
###############################################################################
################################## VARIABLES ##################################
###############################################################################
dockutil=$(which dockutil)
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
@smashism
smashism / super_simple_slack_webhook.sh
Created April 14, 2021 06:00
super simple slack webhook for bash scripts
curl -X POST -H 'Content-type: application/json' --data '{"username": "Clever Name Here","icon_emoji": ":fancy_cat:","text": "Hello, this is your daily reminder that a thing just happened!","channel": "XXXXxXXXx"}' https://hooks.slack.com/services/full/URL/of/configured/incomingwebhook
@smashism
smashism / management-action-by-policy.sh
Last active October 11, 2019 20:33
Add this to a policy in Jamf Pro to send a notification in a more controlled manner than the Start/End notifications in user interaction settings.
#!/bin/bash
###
#
# Name: management-action-by-policy.sh
# Description: This script is designed to run with policies to use
# Management Action.app to send a push notification to
# a managed Mac.
# Use: 1- Add script to Jamf Pro server, and optionally add
# parameter lables that match the parameters below.
@smashism
smashism / checkJPSconnection
Created February 11, 2019 17:54
function to check jamf pro server (JPS) connection in a shell script. jps variable must be set.
function checkJPSConnection {
n=0
until [[ $n -ge 12 ]]; do
checkAvailablity=$(${jamfBinary} checkJSSConnection)
# Function exitStatus
if [[ $checkAvailablity == *"${jps}"* ]]; then
echo "${jps} is available, continuing..."
break
else
echo "${jps} is unavailable at this time. Suspending until next interval..."
@smashism
smashism / privacy-settings-vmwaretoolsdaemon.mobileconfig
Created November 2, 2018 18:00
PPPC profile for vmware-tools-daemon to have accessibility control
<?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>PayloadContent</key>
<array>
<dict>
<key>PayloadDescription</key>
<string>This profile allows vmware-tools-daemon to access Accessibility.</string>
<key>PayloadDisplayName</key>
@smashism
smashism / random_sn
Last active December 10, 2022 15:52
random_sn
randomsn() {
managed_python3 -c "import string; from random import randint, sample; print('VM' + ''.join(sample((string.ascii_lowercase + string.digits),10)))"
}