forked from jorelwilkins/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdatePolicyExecutionFrequencyID.sh
More file actions
68 lines (63 loc) · 2.46 KB
/
updatePolicyExecutionFrequencyID.sh
File metadata and controls
68 lines (63 loc) · 2.46 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
####################################################################################################
#
# THIS SCRIPT IS NOT AN OFFICIAL PRODUCT OF JAMF SOFTWARE
# AS SUCH IT IS PROVIDED WITHOUT WARRANTY OR SUPPORT
#
# BY USING THIS SCRIPT, YOU AGREE THAT JAMF SOFTWARE
# IS UNDER NO OBLIGATION TO SUPPORT, DEBUG, OR OTHERWISE
# MAINTAIN THIS SCRIPT
#
####################################################################################################
#
# DESCRIPTION
# This script will update a specified policy IDs (seperate by commma no spaces) to set the execution frequency to "Once per computer"
#
####################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
read -p "Jamf Pro URL: " server
read -p "Jamf Pro Username: " username
read -s -p "Jamf Pro Password: " password
echo ""
read -p "Policy IDs (comma seperated no spaces): " pid
####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################
# Courtesy of github dot com slash zdorow
echo "Testing connection to Jamf Pro..."
test=$(curl --fail -ksu "$username":"$password" "$server"/JSSResource/users -X GET)
status=$?
if [ $status -eq 6 ]; then
echo ""
echo "The Jamf Pro URL is incorrect. Please edit the URL and try again."
echo "If the error persists please check permissions and internet connection"
echo ""
exit 99
elif [ $status -eq 22 ]; then
echo ""
echo "Username and/or password is incorrect. Please edit and try again."
echo "If the error persists please check permissions and internet connection"
echo ""
exit 99
elif [ $status -eq 0 ]; then
echo ""
echo "Connection test successful! "
echo ""
else
echo ""
echo "Something went really wrong,"
echo "Lets try this again."
exit 99
fi
####################################################################################################
#
# MAIN PROCESS
#
####################################################################################################
data="<policy><general><frequency>Once per computer</frequency></general></policy>"
curl -ksu "$username":"$password" -H "content-type: text/xml" "$server"/JSSResource/policies/id/{$pid} -d "$data" -X PUT