List of All Brew Casks

RickyFH
New Contributor

Hello Everyone,

Does anyone have a method of using an extension attribute to get a list of all casks and formulae installed in our environment?

1 REPLY 1

tdclark
Contributor

I am using an EA to pseudo-track this.  It's not perfect, but it meets what our InfoSec team wants to know.

#!/bin/sh

loggedInUser=$(stat -f %Su /dev/console)

arch=$(/usr/bin/arch)

brewPath=""

if [ "$arch" == "arm64" ]; then
	brewPath="/opt/homebrew/bin/brew"
	
    else
    brewPath="/usr/local/bin/brew"
fi

if [ -e "${brewPath}" ]
    then
        brewed=$(sudo -u "${loggedInUser}" "${brewPath}" list)
 	
	else
		brewed="Nothing Installed"
fi

echo "<result>$brewed</result>"

exit 0