Hi all,
My employer users AnyConnects Always On function which is a nuisance with functions that require graceful shutdowns of macOS like upgrading from Big Sur to Monterey. In the past I have used a script to unload AnyConnects LaunchAgent and kill its PID.
- The script still works fine if run locally, the script kills AnyConnect and it stays dead.
- If run from JAMF Pro via policy with a script payload, AnyConnect opens right back up as soon as the policy finishes.
Maybe some nuance has changed with JAMF and the space at which it runs scrips? Any ideas?
#!/usr/bin/env bash
#* FileName: Cisco-AnyConnect-4-TempDisable.sh
#*=============================================================================
#* Script Name: Cisco-AnyConnect-4-TempDisable
#* Created: []
#* Author:
#*=============================================================================
#* Purpose: Temporarily diable Cisco AnyConnect in order to prevent OS
#* intallations problems, among other uses.
#*=============================================================================
#*=============================================================================
#* REVISION HISTORY
#*=============================================================================
#* Date: []
#* Author:
#* Issue:
#* Solution:
#*=============================================================================
#*=============================================================================
#* FUNCTION LISTINGS
#*=============================================================================
## Unload Cisco AnyConnect Daemon
unloadDaemon()
{
echo " Unloading Cisco AnyConnect Daemon..."
sudo launchctl unload /Library/LaunchAgents/com.cisco.anyconnect.gui.plist
}
killProcess()
{
procList=("AnyConnect")
echo " Killing Cisco AnyConnect process..."
for proc in "${procList[@]}"; do
runningProc=$(ps axc | grep -i "$proc" | awk '{print $1}')
if [[ $runningProc ]]; then
echo " ...Found running process $proc with PID: ${runningProc}. Killing it..."
kill $runningProc
else
echo " ...$proc is not currently running"
fi
done
}
#*=============================================================================
#* SCRIPT BODY
#*=============================================================================
echo "######################################"
echo "Temporarily disabling Cisco Anyconnect"
echo "######################################"
unloadDaemon
killProcess
echo "######################################"
#*=============================================================================
#* END OF SCRIPT
#*=============================================================================