Created
November 13, 2019 14:08
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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