@ntavassoli You have to copy the swda executable to the Mac you want to run it on. To do that you'd:
- Download https://github.com/Lord-Kamina/SwiftDefaultApps/releases/download/v2.0.1/SwiftDefaultApps-v2.0.1.zip
- Copy the swda binary to /usr/local/bin
- Use Composer to create a .pkg installer for the swda binary in that location
- Upload the .pkg you created to your JSS
- Add that .pkg to your Policy that's running the script to set the default apps (make sure the script is set to run After)
Sweet! Im on the right track I believe but when the policy runs it shows this error now:

Is there a way to trust this binary via Jamf so I dont run into this issue via deployment?
Sweet! Im on the right track I believe but when the policy runs it shows this error now:

Is there a way to trust this binary via Jamf so I dont run into this issue via deployment?
@ntavassoli You need to clear the quarantine flag on the swda binary:
sudo xattr -d com.apple.quarantine /Path/to/swda
So it runs successfully but no change is made on either of my test devices. The script shows this output:
Executing Policy Excel and Outlook set as Default
Downloading swda.pkg...
Downloading https://use1-jcds.services.jamfcloud.com//download/2e13a3a0b5bb4bd2b692b75c6965ff80/swda.pkg...
Verifying package integrity...
Installing swda.pkg...
Successfully installed swda.pkg.
Running script Set Excel and Outlook to default apps...
Script exit code: 0
Script result: SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Excel
FWIW, I use the "MailToOutlook_2.0.pkg" hosted on https://macadmins.software/tools/, which was built by Paul Bowden from the Microsoft Mac team. It works like a charm to set Outlook to the default email client. I don't think there's one for Excel, but, I've never had to set Excel to the default in my experience. I guess if Apple Numbers is also installed on the Mac that could end up taking precedence for spreadsheet files.
This is a per-user setting. You have to run each swda command as the logged in user. See the below example.
#!/bin/bash
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name
&& ! /loginwindow/ { print $3 }' )
loggedInUID=$(/usr/bin/id -u "$loggedInUser" 2>/dev/null)
/bin/launchctl asuser "$loggedInUID" /usr/local/bin/swda setHandler --browser --app "/Applications/Google Chrome.app"
exit 0
This is a per-user setting. You have to run each swda command as the logged in user. See the below example.
#!/bin/bash
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name
&& ! /loginwindow/ { print $3 }' )
loggedInUID=$(/usr/bin/id -u "$loggedInUser" 2>/dev/null)
/bin/launchctl asuser "$loggedInUID" /usr/local/bin/swda setHandler --browser --app "/Applications/Google Chrome.app"
exit 0
Still not working for Excel. Do I have this setup correctly?
#!/bin/bash
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name
&& ! /loginwindow/ { print $3 }' )
loggedInUID=$(/usr/bin/id -u "$loggedInUser" 2>/dev/null)
/bin/launchctl asuser "$loggedInUID" /usr/local/bin/swda setHandler --app '/Applications/Microsoft Excel.app' --UTI 'public.comma-separated-values-text'
exit 0
Script is deployed through a Policy that is assigned Once per user per computer. The policy contains the SWDA binary as a package as well.
What you have looks correct. I've tested it on my Mac, and it does not work in that case for Excel/CSV. Unless a logout is required which I'm not doing now. 😁
Have you tested the other commands? What version of macOS are you running? Perhaps swda might have stopped functioning.
But my goodness, trying to insert code in Jamf Nation posts in block or inline is just atrocious now.
And no I'm not a robot, what in the world! 😐
Ended up using MailToOutlook for Outlook and ran a script on each device to remove Numbers from it - this defaults all CSV files to Excel since there is no other app on the machine. An easy workaround as of right now.