Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created February 14, 2018 22:20
Show Gist options
  • Save jcefoli/b9723a700e029c3c903ea3dc65346198 to your computer and use it in GitHub Desktop.
Save jcefoli/b9723a700e029c3c903ea3dc65346198 to your computer and use it in GitHub Desktop.
Time a Powershell Script
# Set Script Start Time
$StartTime = Get-Date
<#
-----------
Your script here
-----------
#>
# Set Script Finish Time and do math
$FinishTime = Get-Date
$TotalTime = ($FinishTime - $StartTime).TotalMilliseconds
Write-Host "This script executed in $TotalTime ms."
# You can change milliseconds to seconds/ minutes etc: https://msdn.microsoft.com/en-us/library/system.timespan_properties(v=vs.110).aspx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment