Skip to content

Instantly share code, notes, and snippets.

@jhbush
Created December 4, 2014 23:29
Show Gist options
  • Save jhbush/e67055b55ee8dd5f330e to your computer and use it in GitHub Desktop.
Save jhbush/e67055b55ee8dd5f330e to your computer and use it in GitHub Desktop.
csv_import_jamf_api
#!/bin/bash
apiUser=ladmin
apiPass=jamf1234
deptList=/Users/ladmin/Desktop/departments.csv
jssURL='https://jssjbush.local:8443'
echo $jssURL
#:Read variables from departments.csv:#
while read inputline;do
line0="$(echo $inputline)"
echo
#:Set auto increment ID:#
idAdd0=$((idAdd0 +1))
echo '<?xml version="1.0" encoding="UTF-8"?>'"<department><name>"$line0"</name></department>" >> ~/Desktop/xmldata$idAdd0.xml
`curl -k -v -u "$apiUser:$apiPass" "$jssURL/JSSResource/departments/id/XXX" -T ~/Desktop/xmldata$idAdd0.xml -X POST`
done < $deptList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment