Skip to content

Instantly share code, notes, and snippets.

@kbeckman
Last active October 28, 2020 15:04
Show Gist options
  • Save kbeckman/4588d6f913add67cb911b7330d2d21e5 to your computer and use it in GitHub Desktop.
Save kbeckman/4588d6f913add67cb911b7330d2d21e5 to your computer and use it in GitHub Desktop.
Windows Keep Awake
# 4 hours...
param($minutes = 240)
$myShell = New-Object -com "Wscript.Shell"
for ($i = 0; $i -lt $minutes; $i++) {
$myShell.sendkeys("{F15}")
Clear-Host
$remaining = $minutes - $i
Write-Output "$remaining minutes remaining..."
Start-Sleep -Seconds 60
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment