initial commit

This commit is contained in:
2021-03-12 13:24:59 -05:00
parent accffd56ae
commit b9b98f9e2f
7 changed files with 373 additions and 0 deletions

59
scripts/jamf-app-usage.py Normal file
View File

@@ -0,0 +1,59 @@
#!/usr/local/bin/python3
#### README ####
#
# Uses the JAMF API to pull application usage for all computers in your environment and export it in a CSV
# Can take a long time depending on your environment and selected date range.
#
#### REQUIREMENTS ####
#
# * Python3 'requests' module (pip3 install requests)
# * JAMF user credentials with read access to computer application usage
#
#### USER VARIABLES ####
# No trailing / please :)
jamf_url=''
api_user = ''
api_password = ''
# date_range = '2021-03-09_2021-03-10' for example
date_range = ''
import requests
from requests.auth import HTTPBasicAuth
import csv
CSVExport = open('JamfAppUsage.csv', 'w', newline='')
writer = csv.writer(CSVExport)
id_computer_list = []
apps_list = []
data_list = []
get_computers = requests.get("%s/JSSResource/computers" % jamf_url, auth=HTTPBasicAuth(api_user, api_password), headers={'Accept': 'application/json'}).json()
for c in get_computers['computers']:
criterias = [c['name'], c['id']]
id_computer_list.append(criterias)
for comp in id_computer_list:
get_usage = requests.get("%s/JSSResource/computerapplicationusage/id/%s/%s" % (jamf_url, comp[1], date_range), auth=HTTPBasicAuth(api_user, api_password), headers={'Accept': 'application/json'}).json()
try:
for u in get_usage['computer_application_usage']:
for a in u['apps']:
writer.writerow([comp[0], u['date'], a['name'], a['open'], a['foreground']])
except Exception as x:
print (x)
CSVExport.close

View File

@@ -0,0 +1,35 @@
#!/bin/sh
#### README ####
#
# The below script moves computer groups from one JAMF instance to another. Useful when setting up a sandbox environment that needs to match prod.
#
#### REQUIREMENTS ####
#
# * JAMF user credentials with read/write access to computer groups
#
#### USER VARIABLES ####
# No trailing / please :)
SOURCE_JAMF_URL=""
DEST_JAMF_URL=""
SOURCE_API_USER=""
SOURCE_API_PASS=""
DEST_API_USER=""
DEST_API_PASS=""
# Pulls group ID numbers from JAMF source and sorts them
PROD_GROUPS=$(curl -X GET "$SOURCE_JAMF_URL/JSSResource/computergroups" -H "accept: application/xml" -u "$SOURCE_API_USER":"$SOURCE_API_PASS" | xml ed -d '//computers' | grep "<id>" | grep -Eo '[0-9]{1,4}' | sort -n)
# Pulls groups from JAMF source and outputs XML files for each group
for id in $PROD_GROUPS; do
curl -X GET "$SOURCE_JAMF_URL/JSSResource/computergroups/id/$id" -H "accept: application/xml" -u "$SOURCE_API_USER":"$SOURCE_API_PASS" | xml ed -d '//computers' > /tmp/jamf/"$id".xml;
done
# Pushes groups to JAMF destination from previously created XML files
for group in /tmp/jamf/*; do
curl -X POST "$DEST_JAMF_URL/JSSResource/computergroups/id/0" -ku "$DEST_API_USER":"$DEST_API_PASS" -T "$group";
done
exit 0

50
scripts/jamf-onboarding.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
#### README ####
#
# This script is intended to be used by IT staff who are manually configuring computers for new hires.
# It must be ran on the user's computer and can be invoked automatically during enrollment or manually via Self Service.
#
# The goal is to assign the computer to a user and then install packages and configurations specific to their department/team.
# It does this by giving computers a temporary Extension Attribute that adds them to a Smart Computer Group in JAMF.
#
#### REQUIREMENTS ####
#
# * Corresponding Extension Attribute that locates the temp file (https://github.com/skoobasteeve/jamfops/ext-attributes/onboarding-group-name.sh)
# * Smart Computer Groups in JAMF that add computers with the corresponding extension attribute.
#
# DON'T FORGET TO EDIT THE GROUP LIST ON LINE 35
# Get user email via a prompt.
results=$( /usr/bin/osascript -e "display dialog \"Assign computer to user:\" default answer \"Email address...\" buttons {\"Cancel\",\"OK\"} default button {\"OK\"}" )
username=$( echo "$results" | /usr/bin/awk -F "text returned:" '{print $2}' )
# Create temporary directory and prompt user to choose onboarding group
tempdir="/tmp/.Onboarding"
if [ -d "$tempdir" ];
then rm -rf "$tempdir"
fi
mkdir "$tempdir"
#### EDIT THIS LIST ####
# This where you would add the individual groups at your org. Use whatever makes sense for you.
# Note the formatting and don't break it.
groupchoice=$( osascript -e 'return choose from list {¬
"DEPARTMENT - TEAM",¬
"DEPARTMENT 2 - TEAM 2",¬
"LAST DEPARTMENT - TEAM 3"}' )
touch /tmp/.Onboarding/"$groupchoice"
# Clean up temp files
find /tmp/.Onboarding -type f -not -name "$groupchoice" -delete
# Run recon and assign email to user
jamf recon -endUsername "$username"
exit 0