Skip to content

Instantly share code, notes, and snippets.

@HokieGeek
Last active July 9, 2019 12:44
Show Gist options
  • Save HokieGeek/114e74c1bed2e07ecdc9c6160c24b709 to your computer and use it in GitHub Desktop.
Save HokieGeek/114e74c1bed2e07ecdc9c6160c24b709 to your computer and use it in GitHub Desktop.
Export the policies from Nexus IQ
#!/bin/bash
iq_host=${1:-"localhost:8070"}
user_pwd=${2:-"admin:admin123"}
cookies="/tmp/cookies"
## Create session
curl --verbose \
--user ${user_pwd} \
--cookie-jar ${cookies} --cookie ${cookies} \
"http://${iq_host}/rest/user/session"
## Export the policies with the given session
curl --verbose \
--user ${user_pwd} \
--cookie-jar ${cookies} --cookie ${cookies} \
--header "X-CSRF-TOKEN: $(awk '/CLM-CSRF-TOKEN/ { print $NF }' ${cookies})" \
"http://${iq_host}/rest/policy/organization/ROOT_ORGANIZATION_ID/export" \
| tee policies_$(date +%Y%m%d%H%M).json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment