Homepage 5 How-to Articles 5 Powershell Script to Put Remote Computer to Sleep

Powershell Script to Put Remote Computer to Sleep

Manage remote endpoints, deploy software and patches with Action1 cloud RMM solution.

Sign up and use free on up to 50 endpoints with no functionality limits or expiration.

April 12, 2019

There are quite a few methods for working with remote computers. There is Windows Management Instrumentation (WMI) widely used in VBScript. There are various utilities that allow remote control, such as PSExec from Sysinternals. Even many PowerShell cmdlets have a ComputerName parameter to run on remote computers.

If you want to bring the device from Windows 10 to sleep without a waiting period of time, you can use the PowerShell sleep command.

At first, 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:

Sleep mode – the system and its processes are paused, the screen goes out and Windows goes into sleep. When you turn off or jump electricity – all active processes and open files will be lost.

Hibernation – processes and open applications are saved to the hyberfil.sys file, the screen goes blank and the device goes into hibernation, in which, if there is a power jump or a sudden shutdown, all files will be saved when you turn it on again. Hibernation is used mainly for laptops, therefore, when the battery is completely discharged, Windows goes into hibernation and restores work from the same place when charging is connected (if the corresponding item is enabled in the settings).
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.

Most of the PowerShell cmdlets are dealing with automation of servers and oddball functions like sleeping a laptop normally would not be a top priority of the Windows Management Foundation / PowerShell group. Enough said… So, this guide shows you how to sleep remote computers with the help of PowerShell.

1. Open Elevated PowerShell Prompt

Recently, Windows 10 users who have encountered some kind of problems could run a particular command in PowerShell to solve these issues. While most of us are familiar with the command line and know how to run the command line as an administrator, not many know how to open the extended PowerShell line. So, today I will show you how to open PowerShell with elevated rights and run it as an administrator in Windows 10.

To open an elevated PowerShell prompt, in the taskbar search, type PowerShell.

Now see the result Windows PowerShell which appears on the top. Right-click on it and select Run as Administrator.

Step 1 to use powershell sleep command is to Run PowerShell as Administrator

Then you will see a confirmation prompt from UAC. Click Yes, and PowerShell will open.

Step 2 to use powershell sleep command is to click yes on UAC prompt

An elevated PowerShell prompt will display Administrator: Windows PowerShell on the top in the prompt’s border.

elevated PowerShell prompt

NOTES: You can also open Task Manager > File menu > Run new task. Type PowerShell and select the Create this task with administrative privileges checkbox and click OK to open an elevated PowerShell prompt.

Run new task Powershell

Press Shift+Ctrl+Alt and then click on the PowerShell icon to open PowerShell as administrator.

Next Step to use powershell sleep command is to open elevated PowerShell prompt

The next step will describe how to use PowerShell sleep command or rather the script.

2. Use This Script to Sleep Remote Computer

PowerShell offers both a console interface and a full-fledged PowerShell ISE (Integrated Scripting Environment, built-in scripting environment) development environment for scripts. In the previous step, we examined how to start the console interface, so we will use it.

Scripts are saved as files with the extension .ps1. Despite the fact that PowerShell has long been a native part of Windows, you cannot run its scripts with a simple double-click. To do this, right-click on the script and select “Run with PowerShell.”

There are also system policies that limit the execution of scripts. You can check the current policy settings by issuing the Get-ExecutionPolicy command. The result will be one of the following values:

  • Restricted – scripting is prohibited. Standard configuration;
  • AllSigned – you can run scripts signed by a trusted developer; Before running the script, PowerShell will ask you for confirmation;
  • RemoteSigned – you can run your own scripts or those signed by a trusted developer;
  • Unrestricted – you can run any scripts.

To get started, you need to change the startup policy setting to RemoteSigned using the Set-ExecutionPolicy command:

Next Step to use powershell sleep command is to use Set-ExecutionPolicy command

Further, you will need to save the script code in a file with the extension .ps1 and execute it in PowerShell with an elevated privileges.

Set-StrictMode –Version latest

Function Sleep-Computer {



Place your computer into Sleep mode


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...


c:\PS>Sleep-Computer -WhatIf

What if: Performing operation "Sleep-Computer" on Target Computer.


c:\PS>Sleep-Computer -Confirm -Force


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"):



param (



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



Consider Using Action1 to Sleep Remote Computer if:

  • You need to perform an action on multiple computers simultaneously.
  • You have remote employees with computers not connected to your corporate network.

Action1 is a cloud-based remote monitoring and management solution for automated patch management, software deployment, remote desktop, software/hardware inventory, and endpoint management.

Related Articles

How To Delete User Profiles Remotely with PowerShell

When a user logs onto the computer for the first time (not via the network to access shared folders or printers), Windows creates a user profile. Among its contents are the NTUSER.DAT file (user profile settings), user-specific folders (My Documents, Desktop, etc.),...

About Action1 RMM

Action1 RMM is a cloud-based IT solution for remote monitoring and management, patching, and remote support.

Start your free two-week trial of Action1, or use RMM tools for free forever on 50 endpoints with no functionality limitations!


Submit a Comment

Your email address will not be published.

cloud patch management solutions action1

MSP Solution

Centralize endpoint management and boost efficiency of IT service delivery.

automated server patch management action compliance

Patch Management

Identify and deploy missing OS and third-party software updates.

cloud software deployment tools windows

Software Deployment

Distribute software and updates across managed endpoints.

software distribution tools software inventory action1

IT Asset Inventory

Keep a detailed inventory and manage hardware and software assets.

web client remote desktop

Remote Desktop

Support users via seamless remote desktop connection.

web based rdp client

Unattended Access

Provide administrative support and manage remote devices.

automated patch management action1

Endpoint Management

Run PowerShell, custom scripts, reboot computers and restart services.

API integrations action1


Integrate Action1 RMM to your IT ecosystem.

computer inventory tool for compliance

Reports and Alerts

Conduct endpoint security audits with comprehensive reporting.