Measure running time (for script blocks and cmdlets).

      Measure-Command [-expression] scriptblock 
         [-inputObject psobject] [CommonParameters]
       The expression to be timed.
       Enclose the expression in {curly braces}

       An object that represents an expression.
       A command, expression or variable that contains the object(s).

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.


Measures the time it takes to run a "get-eventlog" command:

PS C:\> Measure-Command { get-eventlog "windows powershell" }

Compare the performance of -filter and -include:

PS C:\> measure-command {get-childitem c:\windows -include *.txt -recurse}
PS C:\> measure-command {get-childitem c:\windows -filter "*.txt" -recurse}

“There is no monument dedicated to the memory of a committee” ~ Lester J. Pourciau

Related PowerShell Commands:

Compare-Object - Compare the properties of objects
Trace-Command - Trace an expression or command
Invoke-Expression - Run a PowerShell expression
Equivalent bash command: time - Measure program running time

Copyright © 1999-2018
Some rights reserved