mm5
mm5

Reputation: 23

Measure-Command in windows .bat script: command not found

I'm trying to write a script for measure execution time of a program.

If I type the command Measure-Command directly on PowerShell it work.

If I include that command in a script, then PowerShell tell me "command not found".

Can anyone help me please?

Upvotes: 2

Views: 1787

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174485

.bat scripts are not executed by powershell.exe but by cmd.exe. Since Measure-Command is a PowerShell cmdlet, cmd.exe won't recognise it.

You can call PowerShell from a .bat script if you like:

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

Upvotes: 3

Related Questions