How To: Set OSX’s Screen Saver via Script

Standard

Throughout my career as a Mac Admin i’ve often been asked to enforce a screen saver. One environment required a screen saver to always be set, but to allow people to change the desktop background. Another required a screen saver to be set to the corporate standard at each login. This script has been used in both environments to great affect.

MCX is usually a good point to set the screen saver, but if you do not lock down the Desktop & Screensaver preference pane then these settings can be changed.

The below script has been updated & adapted many times since I 1st  posted it on 18/11/2010 I have now tested this script & updated it for 10.8.

When trying to enforce that a screen saver is always in place, i’ve used this script by hardcoding the values of the variables & running it with an every5 trigger in Casper.

When trying to set the corporate screen saver at login, I’ve used a LaunchAgent to run a local copy of the script again with the values hardcoded.