-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUpdateVPPByID.sh
More file actions
64 lines (47 loc) · 1.96 KB
/
UpdateVPPByID.sh
File metadata and controls
64 lines (47 loc) · 1.96 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
#!/bin/sh
# Migrate a set of app id's to a given token and set them to assign or not assign vpp content
################ USER DEFINED VARIABLES START #############################
# Enter credentials and the token id's. If hosting locally use the format https://your.url:8443
# Special characters in the user or password may cause issues with parsing the script
jssURL="https://yoururl.jamfcloud.com"
apiUser="admin"
# apiPass="password"
read -s -p "Password: " apiPass
# set to "true" to use managed distribution, set to "false" to turn off managed distribution
assignVPPContent="true"
# set newToken to -1 to assign to no token, otherwise set to the token's id
newToken="999"
# paste space separated ids between double quotes
ids=""
# specify the endpoint and xml node name for applications
# comment this out to switch to mac applications
endpoint="mobiledeviceapplications"
xmlEndpoint="mobile_device_application"
# comment this back in to switch to mac applications
# endpoint="macapplications"
# xmlEndpoint="mac_application"
################ USER DEFINED VARIABLES END #############################
# base64 encode credentials
auth=$( printf "$apiUser:$apiPass" | base64 )
failedID=""
for id in ${ids[@]}; do
echo "updating $id"
update=$(curl -H "Accept : text/xml" -H "Content-Type: text/xml" -H "authorization: Basic $auth" -ks "$jssURL/JSSResource/$endpoint/id/$id" -w '%{http_code}' -X PUT -d "<${xmlEndpoint}>
<vpp>
<assign_vpp_device_based_licenses>$assignVPPContent</assign_vpp_device_based_licenses>
<vpp_admin_account_id>$newToken</vpp_admin_account_id>
</vpp>
</${xmlEndpoint}>" --output /dev/null)
# report and gather failed updates
if [ "$update" != "201" ]; then
echo "failed $update"
failedID+="$id "
fi
done
# Report failed token updates.
if [ "$failedID" != "" ]; then
echo "The following ids could not be set"
echo "$failedID"
else
echo "All apps have been assigned"
fi