pmset - disablesleep

So I came across a very interesting bug in Profile Manager (running on Server 3) that made it so my users could not sleep their Macbooks - even by closing the lid! Upon closer inspection I noticed that the Sleep button in the MenuBar was also greyed out. So what happened?

In Profile Manager I had configured some settings related to display sleep and disk sleep - but there is certainly nothing related to disabling sleep completely in there!

So the next step - what does pmset sleepnow do? Nothing.
Ok, so pmset -g assertions tells me that different things are preventing sleep on each affected machine. But those assertions are transitory, and they certainly do not prevent the machine from sleeping with the lid closed!
So next - pmset -g. That finally got me somewhere! The first bit of output looked like this:

System-wide power settings:
 SleepDisabled      1
Active Profiles:
Battery Power       -1
AC Power        -1*

So that probably indicates there is a problem right?

I start to think the profiles must be causing the problem (It started when I enrolled people in these new ones), so I remove the offending settings in Profile Manager and send the revised profiles out. That doesn’t help.
From there, I nuked all the profiles on each machine - profiles -dDf and restarted each machine to make sure the Managed Preferences were totally gone.
That didn’t help.

It was about this time that I noticed /Library/Preferences/SystemConfiguration/com.apple.PowerManagement! A quick defaults read informed me that

 SystemPowerSettings =     {
        SleepDisabled = 0;
    };

Long story short, the fix ended up being this command:
pmset -a displaysleep 10 disksleep 10 sleep 30 womp 1 disablesleep 0

That resets your sleep timers back to default, and of course makes disablesleep false.

After all this troubleshooting, I ended up finding other resources that could have helped me more:
http://support.apple.com/kb/ht1191
http://www.coderebel.com/support/faq/How-do-I-make-the-sleep-command-disappear-from-the-Apple-menu
http://derflounder.wordpress.com/2013/01/27/disabling-the-sleep-command-in-the-apple-menu/

edit: I came across this issue again, and I ended up discovering that the problem is not caused by ‘Energy Saver’ preferences like I initially thought. I am managing the Login Window, and I did not have the ‘Show the Sleep, Restart and Shut Down buttons’ option selected. Apparently that is necessary if you want your user’s to be able to sleep their machines!

 
16
Kudos
 
16
Kudos

Now read this

Using AutoPkg

AutoPkg is a tool to help automating the download of new software packages - whether they be updates or full new installations. A large part of the Mac System Admin’s job is making sure that installed software is kept up to date -... Continue →