Last active
August 29, 2022 05:20
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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