QuickTip: PowerShell scripting – How long did it take to run the script?

Have you ever wondered how long it took to run your script? Well, you dont need to wonder anymore. The following couple of lines will provide a visual output how long it take to execute your script from start to finish

$Start = [system.datetime]::Now
{
Script run….
}
$End = [system.datetime]::Now
$resulttime = $End – $Start
Write-Host: (‘Execution Time : {0}Days:{1}Hours:{2}Minutes:{3}Seconds’ -f $Resulttime.Hours, $Resulttime.Days, $Resulttime.Minutes, $Resulttime.Seconds)

Image result for meerkat simples

Regards

The Author – Blogabout.Cloud

Leave a Reply

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