Skip to content

Instantly share code, notes, and snippets.

@fuzzylogiq
Created November 13, 2019 14:08
Show Gist options
  • Save fuzzylogiq/2e7cacd284c204db8884d5a3ed86ce12 to your computer and use it in GitHub Desktop.
Save fuzzylogiq/2e7cacd284c204db8884d5a3ed86ce12 to your computer and use it in GitHub Desktop.
Search JSS Extension Attribute scripts for keywords (I used this to find if we had any python in there)
#!/bin/bash
#set -x
read -p "Enter the search term: " search_term
while read -r line; do
ea=$(curl -s -u $APIUSER:$APIPASS "$APIURL/computerextensionattributes/id/$line")
echo $ea | xmllint --xpath "/computer_extension_attribute/input_type/type[contains(text(), 'script')]/following-sibling::script/text()" - 2> /dev/null | grep -q "$search_term"
[ $? == 0 ] && echo "Extension attribute with id $line contains $search_term"
done <<< "$(curl -su $APIUSER:$APIPASS $APIURL/computerextensionattributes | xmlstarlet sel -t -v '//computer_extension_attributes/computer_extension_attribute/id' -)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment