Mac SCCM 2012 R2 Auto Enrollment

We need to get all the Mac managed by SCCM, but we don’t want people manually type their username and password to enroll. so I have to work a quite script to let mac enroll automatically.

I got the original script from themacwrangler ‘s  blog, and then modified a little bit to suit my environment.

So in my script, I use Apple PackageMaker to create a package called CMEnroll.pkg. This package will copy the Tools folder from the original SCCM Mac client installation package, enroll.sh and expect.sh to /tmp, then run enroll.sh.

“enroll.sh” is using the given username and password to run expect.sh

“expect.sh” is to enroll mac using the microsoft’s sccm command line tool CMEnroll

I use postflight in CMEnroll.pkg to run the enrollment.

#!/bin/sh

/tmp/enroll.sh
exit 0

 

and after I created CMEnroll.pkg, I use Packages to create a combined package, first it runs microsoft sccm installer, then it runs my enrollment script.

#!/bin/sh
install_dir=`dirname $0`
/usr/sbin/installer -dumplog -verbose -pkg $install_dir/”CMClient.pkg” -target “$3″
/usr/sbin/installer -dumplog -verbose -pkg $install_dir/”CMEnroll.pkg” -target “$3”
exit 0

 

Leave a Comment