Skip to main content
Jamf can gather code extension inventories for Secure Annex by defining custom extension attributes. Credit to Tony Young for documenting this.

Create an Extension Attribute

Create a script to retrieve installed VS Code extensions and report them to Jamf Pro.
#!/bin/bash

###################################################################################################
# Script Name:    [installedVSCodeExtensions.sh]
# By:             Fraser Hess
# Organization:   Pinnacol Assurance
# Date:           February 26, 2025
# 
# Purpose:        Retrieve installed extensions within the Visual Studio Code application for macOS
###################################################################################################
# Set Initial Result
result="Not installed"

# Run as the current logged in user to grab their extensions
loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
codePath="/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"

# Check VS Code for installed extensions and include the current version installed
if [[ -e "${codePath}" ]]; then
  result=$(sudo -u "${loggedInUser}" "${codePath}" --list-extensions --show-versions)
fi

# If no extension found, return as such
if [[ -z "${result}" ]]; then
  result="No extensions found"
fi

# Return result for Jamf Pro EA
echo "<result>${result}</result>"
Change the codePath for each code editor you wish to gather inventories for.
/Applications/Cursor.app/Contents/Resources/app/bin/cursor
/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf
View the most current version of this code on Gist.
  1. Save this script.
  2. Create a new Extension Attribute within Jamf Pro. Set the Display name to something appropriate. For Example: Visual Studio Code Installed Extensions or something shorter like CS Code Extensions.
  3. Add a description, then Set the Data Type to String and Input Type to Script.
Jamf extension attributes
  1. Paste the code snippet into the Script section
Jamf extension attributes
  1. Enable and Save changes.
Code extensions will begin to be gathered by Jamf
I