Hello,
You have two ways of getting the execution time for a cmdlet in PowerShell
The first option run the command, and hide the native output to display execution time details. So, if you ran a command, and you want to know, afterward, how long it takes to run, you must run it again inside the “Measure-Command” script block.
Measure-Command { Test-Connection -ComputerName 192.168.1.254 -Count 25}
I personally prefer the second option because you don’t need to run the commands again, and you can compare different cmdlets more easily, that’s nice for script’s performances optimizations.
Get-History | Select-Object CommandLine,@{Label="Duration Time";Expression={$_.EndExecutionTime - $_.StartExecutionTime}}
Of course, you can use both cmdlets on scripts or advanced functions as well.