-
-
Notifications
You must be signed in to change notification settings - Fork 542
Expand file tree
/
Copy pathset-timer.ps1
More file actions
executable file
·32 lines (28 loc) · 677 Bytes
/
set-timer.ps1
File metadata and controls
executable file
·32 lines (28 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<#
.SYNOPSIS
Sets a timer for a countdown
.DESCRIPTION
This PowerShell script sets a timer for a countdown.
.PARAMETER Seconds
Specifies the number of seconds
.EXAMPLE
PS> ./set-timer 60
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([int]$Seconds = 0)
try {
if ($Seconds -eq 0 ) { [int]$Seconds = read-host "Enter number of seconds" }
for ($i = $Seconds; $i -gt 0; $i--) {
Clear-Host
./write-big "T-$i seconds"
Start-Sleep -seconds 1
}
"✅ $Seconds seconds countdown finished"
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}