227 lines
9.4 KiB
Bash
Executable File
227 lines
9.4 KiB
Bash
Executable File
#!/bin/bash
|
||
##############################################################################################################################
|
||
######################## Bestimmen aller Verfügbaren ID´s ####################################################################
|
||
##############################################################################################################################
|
||
# Damit werden alle Patch Policys gelesen.
|
||
# Die ID´s können dann über die Schreife gelesen und in eine Excel übergeben.
|
||
|
||
|
||
|
||
# ++++ curl -X GET "https://macenterprise.jamfcloud.com/JSSResource/patchsoftwaretitles" -H "accept: application/xml"
|
||
|
||
|
||
# Nach ausführung des Befehls wird das folgende Ergebniss ausgegeben:
|
||
# <?xml version="1.0" encoding="UTF-8"?>
|
||
# <patch_software_titles>
|
||
# <size>14</size> <-- Gesamtanzahl aller Patch Policys
|
||
# <patch_software_title>
|
||
# <name_id>0BC</name_id>
|
||
# <source_id>1</source_id>
|
||
# <name>Google Chrome</name> <-- Name der Patch Policy
|
||
# <id>5</id> <-- ID für Google Chrome
|
||
# </patch_software_title>
|
||
# <patch_software_title>
|
||
# <name_id>0A6</name_id>
|
||
# <source_id>1</source_id>
|
||
# <name>Microsoft Word 365</name>
|
||
# <id>8</id>
|
||
# </patch_software_title>
|
||
# <patch_software_title>
|
||
# <name_id>09C</name_id>
|
||
# <source_id>1</source_id>
|
||
# <name>Microsoft Excel 365</name>
|
||
# <id>9</id>
|
||
# </patch_software_title>
|
||
# <patch_software_title>
|
||
# <name_id>JamfProtect</name_id>
|
||
# <source_id>1</source_id>
|
||
# <name>Jamf Protect</name>
|
||
# <id>10</id>
|
||
|
||
|
||
|
||
##############################################################################################################################
|
||
######################## verarbeiten der ID´s ###############################################################################
|
||
##############################################################################################################################
|
||
##############################################################################################################################
|
||
|
||
# Nachdem die ID´s bekannt sind, werde die dann für den Report verarbeitet.Hier das Beispiel der ersten Policy "Google Chrome"
|
||
# die ID ist hier "5"
|
||
|
||
|
||
|
||
# ++++ curl -X GET "https://macenterprise.jamfcloud.com/JSSResource/patchreports/patchsoftwaretitleid/5" -H "accept: application/xml"
|
||
|
||
|
||
|
||
# Nach ausführung des Befehls wird das folgende Ergebniss ausgegeben:
|
||
########## Ergebnis, wo auch ein Gerät nicht die aktuelle Version hat
|
||
# <?xml version="1.0" encoding="UTF-8"?>
|
||
# <patch_report>
|
||
# <name>Google Chrome</name>
|
||
# <patch_software_title_id>5</patch_software_title_id>
|
||
# <total_computers>2</total_computers> <-- Wieviele Geräte sind in der Überwachung
|
||
# <total_versions>270</total_versions>
|
||
# <versions>
|
||
# <version>
|
||
# <software_version>95.0.4638.69</software_version>
|
||
# <computers>
|
||
# <size>1</size> <-- Geräte, auf denen die letzte Version instaliert ist
|
||
# <computer>
|
||
# <id>7</id>
|
||
# <name>MacBook Pro M1 Peter</name>
|
||
# </computer>
|
||
# </computers>
|
||
# </version>
|
||
# <version>
|
||
# <software_version>95.0.4638.54</software_version>
|
||
# <computers>
|
||
# <size>1</size>
|
||
# <computer>
|
||
# <id>20</id>
|
||
# <name>MacBook Pro von Andreas</name>
|
||
|
||
|
||
# Es müssen lediglich beiden Zahlen miteinander verglichen werden.
|
||
# D.h. Die <total_computers>2
|
||
# Abzüglich der Geräte die aktuell sind -
|
||
# <software_version>95.0.4638.69
|
||
# <size>1
|
||
# --------------------------------
|
||
# Geräte noch zu patchen = 1
|
||
|
||
|
||
# Nach ausführung des Befehls wird das folgende Ergebniss ausgegeben:
|
||
########## Ergebnis, wo alle Geräte aktuell sind
|
||
# <?xml version="1.0" encoding="UTF-8"?>
|
||
# <patch_report>
|
||
# <name>Google Chrome</name>
|
||
# <patch_software_title_id>5</patch_software_title_id>
|
||
# <total_computers>2</total_computers> <-- Wieviele Geräte sind in der Überwachung
|
||
# <total_versions>270</total_versions>
|
||
# <versions>
|
||
# <version>
|
||
# <software_version>95.0.4638.69</software_version>
|
||
# <computers>
|
||
# <size>2</size> <-- Geräte, auf denen die letzte Version instaliert ist
|
||
# <computer>
|
||
# <id>7</id>
|
||
# <name>MacBook Pro M1 Peter</name>
|
||
# </computer>
|
||
# <computer>
|
||
# <id>20</id>
|
||
# <name>MacBook Pro von Andreas</name>
|
||
# </computer>
|
||
# </computers>
|
||
# </version>
|
||
# <version>
|
||
# <software_version>95.0.4638.54</software_version>
|
||
# <computers>
|
||
# <size>0</size>
|
||
|
||
# Es müssen lediglich beiden Zahlen miteinander verglichen werden.
|
||
# D.h. Die <total_computers>2
|
||
# Abzüglich der Geräte die aktuell sind -
|
||
# <software_version>95.0.4638.69
|
||
# <size>2
|
||
# --------------------------------
|
||
# Geräte noch zu patchen = 0
|
||
|
||
|
||
##############################################################################################################################
|
||
######################## übergabe der Ergebnisse in eine Datei ###############################################################
|
||
##############################################################################################################################
|
||
##############################################################################################################################
|
||
# Diese Zahlen müssen dann übergeben werden in eine Excel Tabelle.
|
||
|
||
# z.B.
|
||
# Titel Alle Geräte aktuell noch zu patchen
|
||
# <name>Google Chrome</name> <total_computers>2</total_computers> <size>2</size> differenz total zu size
|
||
|
||
|
||
# Es kann auch eine übergabe erfolgen, dass alle ergebnisse, die nicht 0 sind aufgelistet werden.
|
||
# würde jedoch kein einhaltliches Bild der Datei darstellen. Für ein einheitliches Bild der Datei muss kommt also nur die obere Darstellung.
|
||
|
||
# Problem ist hier jedoch, dass nicht alle vom Kunden eingesetzten Titel über das Jamf Pro eingesetzte Patch Management abgebildet werden.
|
||
# Hierzu ist es dann notwendig, dass ein eigenes repository aufgebaut werden muss.
|
||
|
||
|
||
# Grundsätzlich ist es auch möglich, dass der Jamf Pro über den TitelEditor eine weitere Quelle bereitsstellen kann.
|
||
# https://docs.jamf.com/de/title-editor/documentation/Release_History.html
|
||
# Da auch hier die Möglichkeit besteht über die API zuzugreifen, kann Auto PKG warscheinlich die Pflege der Datei zu übernehmen.
|
||
# Hierzu sollte es dann wi folgt aufgebaut sein:
|
||
|
||
# 1. AutoPKG Prüft auf Updates
|
||
# 2. Wenn Update verfügbar, dann download.
|
||
# 3. Diese information, wenn verfügbar dann download, sollte nutzdar sein, dass daraus über API die Versionsnummer aktuallisiert wird.
|
||
|
||
|
||
##############################################################################################################################
|
||
######################## Test der Skripts ####################################################################################
|
||
##############################################################################################################################
|
||
##############################################################################################################################
|
||
|
||
|
||
#****************************************************************************************************************************#
|
||
|
||
|
||
#########################################################################################
|
||
# Shellscript : Skript zur Erstellung eines Patch Reports aller Apps
|
||
# Autor : Andreas Vogel, nextenterprise gmbh
|
||
#########################################################################################
|
||
#set -x
|
||
#########################################################################################
|
||
########################## Server Informations ##########################################
|
||
|
||
|
||
JSSURL="https://macenterprise.jamfcloud.com"
|
||
if [[ $JSSURL = "" ]]; then
|
||
echo "ERROR URL variable is empty"
|
||
exit 1
|
||
fi
|
||
|
||
# Credentials base64
|
||
Credentials=$(echo "QVBJX1VzZXI6TmV4dGVudGVycHJpc2UjMTYxMgo=" | base64 --decode)
|
||
if [[ $Credentials = "" ]]; then
|
||
echo "ERROR no Credentials"
|
||
exit 1
|
||
fi
|
||
|
||
########################## Varialen #####################################################
|
||
TIME=$(/bin/date +"%d.%m.%Y")
|
||
Patch_Report="$HOME/Desktop/Patch_Report_List${TIME}.csv"
|
||
|
||
########################## Creating the report #########################################
|
||
IDs+=($(curl -u $Credentials --tlsv1.2 -H "Accept: application/xml" "$JSSURL/JSSResource/patchsoftwaretitles" | xmllint --format - | awk -F'>|<' '/<id>/{print $3}' | sort -n))
|
||
|
||
echo "Policy ID,Patch Policy Name,All Clients,latest version installed" >> "$Patch_Report"
|
||
set -x
|
||
for id in "${IDs[@]}"; do
|
||
|
||
Titel=$(curl -u $Credentials --tlsv1.2 -H "Accept: application/xml" "$JSSURL/JSSResource/patchreports/patchsoftwaretitleid/$id" | xmllint --xpath '/patch_report/name/text()' - )
|
||
|
||
all_clients=$(curl -u $Credentials --tlsv1.2 -H "Accept: application/xml" "$JSSURL/JSSResource/patchreports/patchsoftwaretitleid/$id" | xmllint --xpath '/patch_report/total_computers/text()' - )
|
||
|
||
Version=$(curl -u $Credentials --tlsv1.2 -H "Accept: application/xml" "$JSSURL/JSSResource/patchreports/patchsoftwaretitleid/$id" | xmllint --xpath '/patch_report/versions/versions/software_version/text()' - )
|
||
|
||
aktuell=$(curl -u $Credentials --tlsv1.2 -H "Accept: application/xml" "$JSSURL/JSSResource/patchreports/patchsoftwaretitleid/$id" | xmllint --xpath '/patch_report/versions/version/computers/size/text()' - )
|
||
|
||
if [[ $aktuell != 0 ]]
|
||
then
|
||
aktuell_1=$aktuell
|
||
else
|
||
aktuell_1=""
|
||
fi
|
||
|
||
|
||
echo "$id,$Titel,$all_clients,$Version,$aktuell_1" >> "$Patch_Report"
|
||
|
||
done
|
||
|
||
echo " " >> "$Patch_Report"
|
||
echo " " >> "$Patch_Report"
|
||
echo " " >> "$Patch_Report"
|
||
echo "Automatically generated patch report on ${TIME}." >> "$Patch_Report"
|
||
echo "This report was created automatically." >> "$Patch_Report"
|
||
|
||
exit 0 |