Enter Hibernation Mode

by Feb 21, 2012

Maybe you are running lengthy tasks at night. Sometimes you may want to place the machine into hibernation once your script is done. Here’s a function that uses a console application to enter hibernation mode:

function Invoke-Hibernate {
    shutdown.exe /H

If you’d rather do this with native .NET methods, here is an alternative:

function Invoke-Hibernate {
    Add-Type AssemblyName System.Windows.Forms
    [System.Windows.Forms.Application]::SetSuspendState(1,0,0) | Out-Null

Remember though that the machine must allow hibernation which is typically turned off for servers. To turn hibernation on, use this:

powercfg.exe /hibernate on

Twitter This Tip! ReTweet this Tip!