Function Start-Timer {
param(
[Parameter(Mandatory=$true)]
[int]$seconds,
[Parameter(Mandatory=$false)]
[switch]$alarm
)
$a = $(Get-Date)
For($i=1;$i -le $seconds;$i++){
Write-Progress -Activity "$seconds Second Timer" -Status $i -PercentComplete $(($i/$seconds)*100) -id 1
Start-Sleep -Seconds 1
}
if($alarm){
For($i=1;$i -le 10;$i++){
[console]::beep(500,300)
}
}
}
Simply call the function with the number of seconds and the optional alarm switch. It will provide a countdown with a progress bar.