PowerTip: Measure the Time for a Command to Complete

PowerTip: Measure the Time for a Command to Complete

Rate This
  • Comments 4

Summary: Learn how to measure the time for a Windows PowerShell command to complete.

Hey, Scripting Guy! Question How can I see how many seconds it takes to retrieve objects from the application log?

  Hey, Scripting Guy! Answer

 (Measure-Command { Get-EventLog application }).totalseconds

Leave a Comment
  • Please add 3 and 6 and type the answer here:
  • Post
  • hi

    "to measure the time for a Windows PowerShell command to complete"

    ---> it can also measure external application (no PowerShell command)

    PS II> (Measure-Command { tasklist /s sv1 }).totalseconds

  • @Walid Toumi this is excellent. I have never thought of using Measure-Command to measure anything but PowerShell ... it makes perfect sense. Cool. Thank you so much for sharing.

  • It took me this long.

    6.2862714

  • Does Measure-Command account for other processes running at the same time as the one you are timing? For example the virus scan kicked in while I was timing a long test of several scripts now I'm not sure which ones are valid tests.

Page 1 of 1 (4 items)