Zurück zum Blog
Guide

Keep a Windows PC Awake With PowerShell: Two Tested Scripts

Keep Windows awake from PowerShell without admin rights: call SetThreadExecutionState to block sleep and screen-off, or press F15 every minute to reset the idle timer. The scripts, how to run and stop them, a powercfg one-liner, and what each does for Teams and Slack.

Slack Green Team
September 23, 2026
September 23, 2026
5 min read
Share:
windows
powershell
remote work

You can keep a Windows PC awake from PowerShell without admin rights in two ways. The clean one calls the Windows API SetThreadExecutionState to tell Windows the system and display are needed, which blocks sleep and screen-off while the script runs and sends no input. The other presses the F15 key every minute with SendKeys, which resets the idle timer, so it also keeps Microsoft Teams green. Neither keeps Slack green: Slack counts only input inside its own window, so an F15 press helps only while Slack is the focused window.

If a green Slack dot is the goal, a script on the PC is the wrong tool. Slack Green keeps your Slack presence active from its own servers during the working hours you set, and the PC can sleep.

Keep a Windows PC awake with PowerShell: SetThreadExecutionState, F15 SendKeys, powercfg, Ctrl+C, Slack no

Script 1: block sleep with SetThreadExecutionState

This asks Windows to keep the system and display on, the same mechanism video players use. It creates no keyboard or mouse input.

# keepawake.ps1 - keeps Windows and the display awake until you press Ctrl+C
$sig = '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);'
$power = Add-Type -MemberDefinition $sig -Name 'Power' -Namespace 'Win32' -PassThru

# ES_CONTINUOUS (0x80000000) | ES_SYSTEM_REQUIRED (0x1) | ES_DISPLAY_REQUIRED (0x2)
$null = $power::SetThreadExecutionState([uint32]2147483651)
Write-Host "Keeping this PC awake. Press Ctrl+C to stop."
try {
    while ($true) { Start-Sleep -Seconds 60 }
} finally {
    $null = $power::SetThreadExecutionState([uint32]2147483648)   # ES_CONTINUOUS: back to normal
}

Check it works: in a second PowerShell window run powercfg /requests. PowerShell appears under DISPLAY and SYSTEM while the script runs.

Script 2: press F15 every minute

F15 is a key no keyboard has, so most apps ignore it, but Windows counts it as input.

# f15.ps1 - presses F15 once a minute until you press Ctrl+C
$shell = New-Object -ComObject WScript.Shell
while ($true) {
    $shell.SendKeys('{F15}')
    Start-Sleep -Seconds 60
}

Because it is input, it resets the idle timer that Teams uses, so Teams usually stays Available. It sends the key to whatever window is in focus. Software input like this is marked as injected by Windows and can be seen by monitoring tools; see can a mouse jiggler be detected.

How to run and stop a PowerShell keep-awake script

Nie wieder "abwesend" auf Slack erscheinen

Cloud-basiert. Keine Downloads. Funktioniert 24/7 auch wenn Ihr Laptop aus ist.

Run a keep-awake script: save, open PowerShell, run with Bypass, stop with Ctrl+C

  • Paste a script into Notepad and save it as keepawake.ps1.
  • Open PowerShell (no admin needed) and go to the folder.
  • Run: powershell -ExecutionPolicy Bypass -File .\keepawake.ps1
  • Press Ctrl+C or close the window to stop. Windows goes back to its normal power settings.

If your company blocks PowerShell scripts, do not work around the policy. Use the settings or tools in keep a work computer awake without admin rights instead.

Batch and cmd: change the timeouts instead

To stop sleep while plugged in, without a running script:

powercfg /change standby-timeout-ac 0
powercfg /change monitor-timeout-ac 0

0 means never. Set them back later with the minutes you want, for example powercfg /change standby-timeout-ac 30. On a managed PC these may be locked by policy.

Which script to use

Which keep-awake script to use: sleep, Teams and Slack effects compared
ScriptStops sleepTeams greenSlack green
SetThreadExecutionStateYesNoNo
F15 every minuteYesUsuallyOnly with Slack focused
powercfg timeoutsYes, plugged inNoNo
Slack Green scheduleNot neededNo, Slack onlyYes

For Teams timings see how long before Teams shows you as Away. For Slack, the rules are in how long does Slack stay active, and Windows options in keep Slack active on Windows. The ready-made app equivalent of script 1 is PowerToys Awake; see does PowerToys Awake keep Slack active.

FAQ

Nie wieder "abwesend" auf Slack erscheinen

Cloud-basiert. Keine Downloads. Funktioniert 24/7 auch wenn Ihr Laptop aus ist.

How do I keep my computer awake with PowerShell?

Run a script that calls SetThreadExecutionState with the system and display flags, or one that presses F15 every minute.

Does a PowerShell script keep Teams green?

The F15 script usually does, because it is input. The SetThreadExecutionState script does not.

Does a PowerShell script keep Slack active?

No, unless the Slack window is focused and receives the keypress. Slack counts only input in its own window.

Do I need admin rights?

No, unless your company blocks PowerShell scripts.

How do I stop the script?

Press Ctrl+C or close the PowerShell window.

Always Active

Hör auf, die Maus zu Bewegen.

Hunderte Remote-Arbeiter sorgen sich nicht mehr um ihren Slack-Status. Einmal einrichten, für immer grün bleiben.

Related Articles

Guide

Slack Huddles vs Zoom: Which to Use for Team Calls

Slack huddles are quick calls inside Slack: 1:1 on the free plan, up to 50 people on paid plans, no recording. Zoom is built for scheduled, recorded and large meetings, with a free plan of 100 people for 40 minutes. Limits, cost, recording and privacy side by side.

Slack Green Team5 min read
Guide

How to Work Two Remote Jobs at the Same Time

Working two remote jobs at once takes four things: contracts that allow it, fully separate devices and accounts, a calendar that protects both jobs, and a chat status that stays believable in both. The practical setup, and the risks.

Slack Green Team5 min read
Guide

How Do Employers Monitor Remote Workers? What Each Tool Sees

Employers monitor remote workers through five layers: work apps like Slack and Teams, laptop management, monitoring software, the network, and your output. What each one sees, how to check your own laptop, and what the law says.

Slack Green Team5 min read
    Keep Computer Awake With PowerShell: 2 Scripts