Enter Hibernation Mode

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!


Posted Feb 21 2012, 06:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.