PowerTip: Measure the Time for a Command to Complete

PowerTip: Measure the Time for a Command to Complete

  • Comments 5
  • Likes

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • 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.

  • It took me this long: 1.1570565 That's with Windows 8.1 Ent (2)SSD in Sata Array 5 (not true RAID)