-
Notifications
You must be signed in to change notification settings - Fork 1
/
EADump.py
32 lines (25 loc) · 1.08 KB
/
EADump.py
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
#!/usr/bin/python
#/Users/Shared/ExtensionAttributes/ has to exist or it fails
import urllib2
import base64
import json
import sys
import ssl
import os
import requests
import requests.packages.urllib3
APIUsername='username'
APIPassword='password'
JamfProServer='https://YOURJAMFPROSERVER:8443/'
r=requests.get(JamfProServer + 'JSSResource/computerextensionattributes', auth=(APIUsername,APIPassword), headers={'accept': 'application/json'})
EAs = r.json()['computer_extension_attributes']
requests.packages.urllib3.disable_warnings()
for record in EAs:
z=requests.get(JamfProServer + 'JSSResource/computerextensionattributes/id/%s' % record['id'], auth=(APIUsername,APIPassword), headers={'accept': 'application/json'})
if z.json()['computer_extension_attribute']['input_type']['type'] == "script":
scriptfile = "/Users/Shared/ExtensionAttributes/" + record['name'] + ".sh"
contents = z.json()['computer_extension_attribute']['input_type']['script'].encode("ascii", 'ignore'))
contents = contents.replace("\r","")
target = open(scriptfile, 'w')
target.write(contents)
target.close()