Posted on 11-07-2018 08:12 AM
Hi Folks!
Upper management asked if I could create a script to manage the power settings for our iMacs. The built in config profile settings in the JSS don't seem to match and they couldn't get it to work to their specs. So I came up with a script to set the Energy Saver prefs in System Preferences the way they'd like them set for now. But having a little trouble. When I push it via Casper, sometimes it works and sometimes it doesn't. But when I run the script from the local machine, works every time. I was wondering if there needs to be a little more 'logic' to the script for it to work in a Casper policy. If anyone can see. Here's what I have scripted with screenshot of what they want:
#!/bin/bash
# Sets Turn Display Off after... Never
systemsetup -setsleep never
# Sets Prevent computer from sleeping automatically
systemsetup -setcomputersleep never
# Sets Put Hard Disks to Sleep when possible off
pmset -c disksleep 0
# Sets Wake for network acccess to on
systemsetup -setwakeonnetworkaccess on
# sets Startup automatically after a power failure
systemsetup -setrestartpowerfailure on
# turns off Power Nap in Energy Saver
pmset -c darkwakes 0
# Turns on the Schedule power on weekdays at 12am in Schedule button
pmset repeat wakeorpoweron weekdays 00:00:00
exit 0
Posted on 05-03-2019 07:34 AM
Thanks for the script. I was able to run with Jamf and it did exactly what you indicated!
Posted on 05-03-2019 10:28 AM
Here's what I do for this, in case it helps anyone else... ( our screen lock policy)
So, if a user sets a time over 20mins, Jamf sets it back to 20/5 (power/battery) at some point, they can run higher for a while but useally in 1 day it kicks back. This lets them change it anywhere from 0-20, but if they go over Jamf will eventually catch them. Yes the stubborn user can avoid this changing it daily, but they cant avoid the 20min screen saver. So really its just a power saving thing. Keeps the screens off as much as possible.
Heres our EA
#!/bin/sh
echo "<result>`/usr/bin/pmset -g 2>&1 | grep displaysleep | awk '{print $2}'`</result>"
Heres our Display Sleep (use parameters for the values)
#!/bin/bash
#set Display sleep Battery
pmset -b displaysleep $4
#set Display sleep power Adapter
pmset -c displaysleep $5
#set Display sleep ups
pmset -u displaysleep $6
Not sure if this is KISS or not with all the layers, but we try...
Posted on 05-29-2019 03:16 PM
I have scheduled to make all iMacs at my office come on at 6am in the mornings on weekdays (and going off at 7pm). I don't really want to mess up this schedule, but I want a one-time exception to have them NOT come on on a specific day (Bank Holiday). Any suggestions?
Posted on 06-27-2019 09:18 AM
@ScottSimmons Re: #3. I was recently playing around with a configuration profile to control display sleep on portables and while it's true that a user can go in after the fact and change the value set in the config profile, it doesn't stay for long. There is a time frame where the config profile is enforced and the value changes back. Sounds like what you're doing manually with the script. FYI.
Posted on 10-08-2019 09:26 AM
@ScottSimmons thanks for your post! It was very helpful. Your EA displays whichever sleep setting is currently active so will vary based on if User is on battery or power adaptor when inventory is run. I set up this EA to display of whichever one is greater.
#!/bin/bash
## sleep time EA
displaySleepBatt=`pmset -g custom | awk '/Battery Power/{f=1} /disksleep/{f=0;print} f' | grep "displaysleep" | awk '{print $2'}`
displaySleepPower=`pmset -g custom | awk '/AC Power/{f=1} /disksleep/{f=0;print} f' | grep "displaysleep" | awk '{print $2'}`
## determine if battery or power adaptor setting is greater
if (( $displaySleepBatt > $displaySleepPower )) ; then
greater=$displaySleepBatt
else
greater=$displaySleepPower
fi
echo "<result>$greater</result>"
exit 0