Windows 8: Enable/Disable Hibernate via PowerShell
If you newly installed Windows 8.1 and you would like to disable Hibernate, you figured out by now that you can’t simply do powercfg /h off like you used to be able to in Windows 7, you get this Windows error codes:
An unexpected error condition has occurred. Unable to perform operation. You may not have permission to perform this operation.
Here’s an easy way to do it, by not changing anything permission related (UAC etc.) on your system.
Disable Hibernate
Start a command prompt, or run directly, paste this and hit enter:
powershell -Command "Start-Process 'powercfg.exe' -Verb runAs -ArgumentList '/h off'"
Enable Hibernate
Start a command prompt, or run directly, paste this and hit enter:
powershell -Command "Start-Process 'powercfg.exe' -Verb runAs -ArgumentList '/h on'"
Check Hibernate Status
Start a command prompt, or run directly, paste this and hit enter:
powershell -Command "Get-ItemProperty HKLM:SYSTEMCurrentControlSetControlPower -name HibernateEnabled; Pause"
I think the quicker way of doing it might be to start the cmd.exe shell with administrator rights (run as adrministrator).
Of course it would.
Now explain to someone how to easily run cmd.exe as admin in Win8 🙂
Very simple, just keep Ctrl+Shift when you click on the “cmd.exe” icon/test 🙂
Right click on the start button and choose command prompt (Admin)
Well, it work under the command line but how to integrate it in PS script without any prompts ?