-
Notifications
You must be signed in to change notification settings - Fork 37
/
list_computers_no_check-in_time.sh
49 lines (31 loc) · 1.76 KB
/
list_computers_no_check-in_time.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# This script was written when I noticed a number of machines with no Last-Check-in date in the JSS. Depending
# on the size of your enterprise and the number of enrolled computers, this script will take some time to complete.
# You can pipe the results to a file to save the results. Otherwise the output is to stdout.
# Author: Andrew Thomson
# Date: 08-10-2016
#JSS_USER="" # Un-comment this line and add your login name if different from your os x login account.
#JSS_PASSWORD="" # Un-comment this line and add your password to prevent being prompted each time.
if ! JSS_URL=`/usr/bin/defaults read com.jamfsoftware.jss.plist url`; then
echo "ERROR: Unable to read default url."
exit $LINENO
fi
if [ -z $JSS_USER ]; then
JSS_USER=$USER
fi
if [ -z $JSS_PASSWORD ]; then
echo "Please enter JSS password for account: $USER."
read -s JSS_PASSWORD
fi
# get computers ids
COMPUTERS=(`/usr/bin/curl -X GET -H"Accept: application/xml" -s -u ${JSS_USER}:${JSS_PASSWORD} ${JSS_URL}JSSResource/computers | /usr/bin/xpath "//id" 2> /dev/null | awk -F'</?id>' '{for(i=2;i<=NF;i++) print $i}'`)
# enumerate computers for last check-in time
for COMPUTER in ${COMPUTERS[@]}; do
LAST_CONTACT_TIME=`/usr/bin/curl -X GET -H"Accept: application/xml" -s -u ${JSS_USER}:${JSS_PASSWORD} ${JSS_URL%/}/JSSResource/computers/id/$COMPUTER/subset/general | /usr/bin/xpath "/computer/general/last_contact_time/text()" 2> /dev/null`
if [ "$LAST_CONTACT_TIME" == "" ]; then
/usr/bin/curl -X GET -H"Accept: application/xml" -s -u ${JSS_USER}:${JSS_PASSWORD} ${JSS_URL%/}/JSSResource/computers/id/$COMPUTER/subset/general | /usr/bin/xpath "/computer/general/name/text()" 2> /dev/null
echo $'\r'
fi
done
# audible completion sound
/usr/bin/afplay /System/Library/Sounds/Glass.aiff