You can use this script to schedule maintenance mode for SCOM 2012 and 2012 R2. If you however have upgraded to 2016 I recommend using the built-in maintenance scheduler instead.

Read my blog post at http://blog.orneling.se/2014/01/schedule-operations-manager-maintenance-mode/ for more information on how to use the script.