Powershell Tip #106: Create, (re)start, stop and reset a stopwatch

By | August 13, 2016

Tip: You can create a stopwatch in Powershell using the Stopwatch class.

Create and Start
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

Stop
$stopwatch.Stop()

Elasped Time
$stopwatch.Elapsed

create-stopwatch-powershell-elapsed

Reset
$stopwatch.Reset()

create-stopwatch-powershell-reset-elapsed

Restart
$stopwatch.Restart()

create-stopwatch-powershell-restart-elapsed

Note: The property Isrunning indicates whether if the stopwatch is running.

create-stopwatch-powershell-isrunning


previous-buttonnext-button

One thought on “Powershell Tip #106: Create, (re)start, stop and reset a stopwatch

  1. Pingback: Powershell Tip #107: Bulk rename filenames to title case | Powershell Guru

Leave a Reply

Your email address will not be published. Required fields are marked *