Powershell show elapsed time $Time = [System.Diagnostics.Stopwatch]::StartNew() while ($true) { $CurrentTime = $Time.Elapsed write-host $([string]::Format("`rTime: {0:d2}:{1:d2}:{2:d2}", $CurrentTime.hours, $CurrentTime.minutes, $CurrentTime.seconds)) -nonewline sleep 1 if ($Host.UI.RawUI.KeyAvailable -and ("q" -eq $Host.UI.RawUI.ReadKey("IncludeKeyUp,NoEcho").Character)) { Write-Host "Exiting now" break; } $Time = [System.Diagnostics.Stopwatch]::StartNew() while ($NoEvent) { $CurrentTime = $Time.Elapsed write-host $([string]::Format("`rTime: {0:d2}:{1:d2}:{2:d2}", $CurrentTime.hours, $CurrentTime.minutes, $CurrentTime.seconds)) -nonewline sleep 1 #Handle event if(event){$NoEvent = false} }