Skip to content

Instantly share code, notes, and snippets.

@dpo007
Last active August 29, 2022 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpo007/dbaa3eb66f8c8dae708b20adceaefc3d to your computer and use it in GitHub Desktop.
Save dpo007/dbaa3eb66f8c8dae708b20adceaefc3d to your computer and use it in GitHub Desktop.
PowerShell :: Simple loop to run commands at a certain time in the future.
$endTime = Get-Date "4:45PM"
Do {
$timeNow = Get-Date
if ($timeNow -ge $endTime) {
Write-Host "Ding! It's $endTime, time to work..."
# Do Stuff
Break
} else {
cls
Write-Host "Waiting until $endTime (Currently: $timeNow)"
}
Start-Sleep -Seconds 1
} Until ($timeNow -ge $endTime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment