Suspend or hibernate from PowerShell

Viewed 40339

I am interested in using Windows PowerShell to suspend or hibernate a computer. How do you achieve this?

I am already aware of the Stop-Computer and Restart-Computer cmdlets, which are included out of the box, but these do not achieve the functionality that I am after.

4 Answers

I tried reducing this down to a one-liner but was getting an error. Here's my solution:

[Void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
[System.Windows.Forms.Application]::SetSuspendState("Hibernate", $false, $false);
Related