I am currently trying to find out if there is a way to hardcode the password that subsequentially shows up after the bash script below is ran. The idea is we deploy this via our MDM solution and then run it and it removes the user from having the local admin privileges on our Macs.
#!/bin/bash
loggedInUser=`/usr/bin/stat -f%Su /dev/console`
if [ "$CurrentUser" == "root" ] || [ "$CurrentUser" == "localadmin" ] ; then
exit 0
fi
#removes user from the admin group (post-uninstall)
sudo dseditgroup -o edit -d Username -t user admin