Hello all,
I had a request to inventory all Edge extensions in our environment so we can consider whitelisting/blacklisting extensions. I was able to modify the script in this Chrome EA from Jamf's GitHub to fit our needs. Specifically, I needed to modify it to look at Edge's data folder and to check all users on the client instead of just the currently logged in one or last user. I'm providing my modified script below in case it's helpful to anyone else looking to do the same.
#!/bin/bash
# Setting IFS Env to only use new lines as field separator
IFS=$'\\n'
result="NA"
createChromeExtList ()
{
for userHome in /Users/*
do
user=`echo $userHome | rev | cut -d"/" -f1 | rev`
if [ -d "$userHome/Library/Application Support/Microsoft Edge/Default/Extensions" ]
then
for manifest in $(find "$userHome/Library/Application Support/Microsoft Edge/Default/Extensions" -name 'manifest.json')
do
name=$(cat $manifest | grep '"name":' | awk -F "\\"" '{print $4}')
if [[ `echo $name | grep "__MSG"` ]]
then
msgName="\\"`echo $name | awk -F '__MSG_|__' '{print $2}'`\\":"
if [ -f $(dirname $manifest)/_locales/en/messages.json ]
then reportedName=$(cat $(dirname $manifest)/_locales/en/messages.json | grep -i -A 3 "$msgName" | grep "message" | head -1 | awk -F ": " '{print $2}' | tr -d "\\"")
elif [ -f $(dirname $manifest)/_locales/en_US/messages.json ]
then reportedName=$(cat $(dirname $manifest)/_locales/en_US/messages.json | grep -i -A 3 "$msgName" | grep "message" | head -1 | awk -F ": " '{print $2}' | tr -d "\\"")
fi
else
reportedName=$(cat $manifest | grep '"name":' | awk -F "\\"" '{print $4}')
fi
version=$(cat $manifest | grep '"version":' | awk -F "\\"" '{print $4}')
extID=$(basename $(dirname $(dirname $manifest)))
# This is the default output style - looks nice in JSS
# Comment out line below if you wish to use alternate output
echo -e "User: $user\\nName: $reportedName \\nVersion: $version \\nID: $extID \\n"
# This is the alternate output style - looks ugly in JSS, but possibly more useful
# Uncomment line below to use this output instead
# echo -e "$user;$reportedName;$version;$extID"
done
fi
done
}
result="`createChromeExtList`"
echo -e "<result>$result</result>"