Skip to content

Instantly share code, notes, and snippets.

Avatar

Eryk evoelker

  • In a rabbit hole.
View GitHub Profile
@ctigeek
ctigeek / Start-Sleep.ps1
Created Mar 23, 2016
Powershell sleep function, with progress bar.
View Start-Sleep.ps1
function Start-Sleep($seconds) {
$doneDT = (Get-Date).AddSeconds($seconds)
while($doneDT -gt (Get-Date)) {
$secondsLeft = $doneDT.Subtract((Get-Date)).TotalSeconds
$percent = ($seconds - $secondsLeft) / $seconds * 100
Write-Progress -Activity "Sleeping" -Status "Sleeping..." -SecondsRemaining $secondsLeft -PercentComplete $percent
[System.Threading.Thread]::Sleep(500)
}
Write-Progress -Activity "Sleeping" -Status "Sleeping..." -SecondsRemaining 0 -Completed
}