If you want to bring the device from Windows 10 to sleep without waiting period of time, you can use the powershell sleep command.
To begin with, it is worth explaining that sleep mode is a low-power state in which the system suspends processes and activity and turns off the display in order to save energy as much as possible. This is a kind of alternative to shutting down, but with the ability to quickly wake up a computer and continue working at the point where you left off.
In fact, there are several types of sleep mode:
But there are also questions - hybrid sleep mode in Windows 10, what is it? In fact, this is hibernation, but only for stationary computers. It combines saving all active applications to a file, as in hibernation and fast waking up, as in sleep mode. In Windows 10, this term is not used and is referred to as hibernation, both on stationary PCs and laptops.
Under the concept of sleep mode in Windows 10, we will perceive all 3 types (sleep, hibernation and hybrid), since they have common settings and work according to a general principle.
Well, there was not one. Most of the PowerShell cmdlets are dealing with automation of servers and odd ball functions like sleeping a laptop normally would not be a top priority of the Windows Management Foundation / PowerShell group. Enough said... So, this guide show you how to sleep remote computers with help of PowerShell.
The next step will describe how to use powershell sleep command or rather the script.
Set-StrictMode –Version latest
- Function Sleep-Computer {
- #
- .SYNOPSIS
- Place your computer into Sleep mode
- .DESCRIPTION
- Since there is not a cmdlet that will 'sleep' your computer, the Sleep-Computer function was born. You can use
- the force option to override/clear your hibernate setting and then sleep if you need to...
- .EXAMPLE
- c:\PS>Sleep-Computer -WhatIf
- What if: Performing operation "Sleep-Computer" on Target Computer.
- .EXAMPLE
- c:\PS>Sleep-Computer -Confirm -Force
- Confirm
- Are you sure you want to perform this action?
- Performing operation "Sleep-Computer" on Target "V-RONEES-W8MBP".
- [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
- #>
- [cmdletbinding(SupportsShouldProcess=$True,ConfirmImpact="Low")]
- param (
- [parameter(mandatory=$false)][switch]$Force
- )
- if ($pscmdlet.ShouldProcess($env:COMPUTERNAME)) {
- if ($Force.IsPresent) {
- if ($pscmdlet.ShouldProcess("Turning off hibernation")) {
- & powercfg -hibernate off
- }
- }
- $rundll = Join-Path -Path ($env:windir) -ChildPath "System32\rundll32.exe"
- & ($rundll) powrprof.dll,SetSuspendState 0,1,0
- }
- }
Also consider using Action1 to sleep remote computer if: