function CountDown($waitMinutes) {
$startTime = get-date
$endTime = $startTime.addMinutes($waitMinutes)
$timeSpan = new-timespan $startTime $endTime
write-host "`nSleeping for $waitMinutes minutes..." -backgroundcolor black -foregroundcolor yellow
while ($timeSpan -gt 0) {
$timeSpan = new-timespan $(get-date) $endTime
write-host "`r".padright(40," ") -nonewline
write-host $([string]::Format("`rTime Remaining: {0:d2}:{1:d2}:{2:d2}", `
$timeSpan.hours, `
$timeSpan.minutes, `
$timeSpan.seconds)) `
-nonewline -backgroundcolor black -foregroundcolor yellow
sleep 1
}
}
while (-1) {
Countdown 1
}
No comments:
Post a Comment