windows中的测量命令。bat脚本:未找到命令

windows中的测量命令。bat脚本:未找到命令,windows,powershell,time,measurement,Windows,Powershell,Time,Measurement,我正试图编写一个脚本来测量程序的执行时间 如果我直接在PowerShell上键入命令Measure命令,它会工作 如果我在脚本中包含该命令,则PowerShell会告诉我“未找到命令” 有人能帮我吗?.bat脚本不是由powershell.exe执行的,而是由cmd.exe执行的。由于Measure命令是PowerShell cmdlet,cmd.exe无法识别它 如果愿意,可以从.bat脚本调用PowerShell: powershell -command "Measure-Command {

我正试图编写一个脚本来测量程序的执行时间

如果我直接在PowerShell上键入命令
Measure命令
,它会工作

如果我在脚本中包含该命令,则PowerShell会告诉我“未找到命令”


有人能帮我吗?

.bat
脚本不是由
powershell.exe执行的,而是由
cmd.exe执行的。由于
Measure命令
是PowerShell cmdlet,cmd.exe无法识别它

如果愿意,可以从
.bat
脚本调用PowerShell:

powershell -command "Measure-Command {Do-Something -Param1 stuff}|Select -Exp TotalSeconds" >> timing.txt

谢谢你的回答!:)所以我必须编写一个cmdlet并包含命令“Measure command”?