Measure-Command

测量运行脚本块和 cmdlet 所需的时间。

语法

Default (默认值)

Measure-Command
    [-InputObject <PSObject>]
    [-Expression] <ScriptBlock>
    [<CommonParameters>]

说明

Measure-Command cmdlet 在内部运行脚本块或 cmdlet,将操作的执行时间超时,并返回执行时间。

参数

-Expression

指定正在计时的表达式。 将表达式括在大括号({})。 参数名称(“表达式”)是可选的。

参数属性

类型:ScriptBlock
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

绑定到 InputObject 参数的对象是传递给 ScriptBlock 参数的 Expression 的可选输入。 在 ScriptBlock内,$_ 可用于引用管道中的当前对象。

参数属性

类型:PSObject
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输入

PSObject

可以通过管道将对象传递给 Measure-Command

输出

TimeSpan

Measure-Command 返回表示结果的时间跨度对象。