Created
September 6, 2024 20:16
-
-
Save nanoDBA/4a25452c78d2127f96e1a8da7bb3785b to your computer and use it in GitHub Desktop.
Sleep 5 hours in console/script
This file contains hidden or 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
# Store TimeSpan object in variable $timespan | |
$timespan = New-TimeSpan -Start (Get-Date) -End (Get-Date).AddHours(5) #(Get-Date).AddDays(1).Date.AddHours(5) #careful with this - syntax is weird | |
# Print a message to the console in magenta color indicating the time the script will resume execution | |
Write-Host -ForegroundColor magenta "Sleeping until $((Get-date).AddSeconds($timespan.TotalSeconds)) ..." | |
# Pause the execution of the script for a number of seconds equal to the total seconds of the $timespan | |
Start-Sleep -Seconds $timespan.TotalSeconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment