Email notifications during imaging

fidg0010
New Contributor II

During our Windows OSD through SCCM we receive an email as the image starts and finishes. Would also like to get this working while imaging MacOS devices via JAMF Pro. Has anyone got this working or could provide some advice on how to achieve this?

6 REPLIES 6

AVmcclint
Honored Contributor

I've setup a Smart Group that notifies me when a computer is added that has the latest version of the OS (in our case 10.12.6) I use this as a sign that imaging is completed. It doesn't necessarily mean that all the post-imaging tasks are completed (like joining AD and installing required apps), but when I get that email I know that the imaging itself is done and the computer has rebooted and collected an initial inventory.

allanp81
Valued Contributor

We do something like that emails a noticeboard to say machine name, workflow used etc.

Can share if you're interested.

Brad_G
Contributor II

@allanp81 , I'd be interested to see what you're doing. We do the OSD email notification here and our on-site folks could benefit from something from the Mac side as well.

Thanks in advance.

fidg0010
New Contributor II

@allanp81 would love to see what you guys are doing. I've been racking my brain trying to work out a way in which we can achieve this.

fidg0010
New Contributor II

@AVmcclint I will give that a go and see how it works out for me, however I was looking for something that might confirm that the imaging process has completed successfully.

allanp81
Valued Contributor

@fidg0010 We simply have a script named the same as the imaging workflow name, added to Jamf. We then run this at the end of the imaging process:

#!/bin/bash
#Logs which imaging workflow was run

#make sure log directory exists
if [ ! -d "/Library/Application Support/KingstonUniversity" ]; then
  mkdir "/Library/Application Support/KingstonUniversity/"
fi

#set log file location to log outcome of operation
logfile="/Library/Application Support/KingstonUniversity/kuworkflow.log"

#get the date and time
addDate(){
        while IFS= read -r line; do
            echo "$(date) $line"
        done
    }

#print workflow name based on script name
printf '%s
' "${0##*/}" | cut -f 1 -d '.' |addDate >> "$logfile"

workflow=$( printf '%s
' "${0##*/}" | cut -f 1 -d '.' )

echo $workflow

#Check that the smtp server is being specified in /etc/postfix/main.cf
if grep 'your smtp server here' /etc/postfix/main.cf
    then
        echo "SMTP server already configured"
    else
        echo "SMTP server not configured, adding now"
        echo "relayhost = your smtp server here" >> /etc/postfix/main.cf
    fi



echo "Emailing ServiceDesk"
sendmail -f from@someone.com -t to@someone.com <<EOF
Subject: Casper (Service Orchestration) Audit Information
Machine $HOSTNAME imaged with $workflow workflow

EOF