使用Measure-Command时获取无业游民进程的输出

时间:2018-11-19 12:45:42

标签: powershell vagrant output stdout metrics

我想在配置Vagrant开发机器时收集一些指标,并发现Measure-Command。但是运行Vagrant命令时没有任何输出:

PS VagrantTest> Measure-Command {vagrant up}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 14
Milliseconds      : 183
Ticks             : 141838408
TotalDays         : 0,000164164824074074
TotalHours        : 0,00393995577777778
TotalMinutes      : 0,236397346666667
TotalSeconds      : 14,1838408
TotalMilliseconds : 14183,8408

独立运行Vagrant时,我获得了有关进度的更多信息,如下所示:

PS VagrantTest> vagrant up
Bringing machine 'rancher-base-box' up with 'virtualbox' provider...
==> rancher-base-box: Checking if box 'ubuntu/xenial64' is up to date...
==> rancher-base-box: A newer version of the box 'ubuntu/xenial64' for provider 'virtualbox' is
==> rancher-base-box: available! You currently have version '20181113.0.0'. The latest is version
==> rancher-base-box: '20181114.0.0'. Run `vagrant box update` to update.
[...]

我的目标是查看流浪汉的常规输出并在命令完成后显示其执行时间的度量。使用Measure-Command可以工作吗?还是需要自己使用(Get-Date).MillisecondsStopWatch来收集执行时间?

按照KISS原则,我想使用现有命令而不是编写自己的度量标准。

1 个答案:

答案 0 :(得分:0)

尝试Start-process -RedirectStandardOutput吗?

它将输出到文件 doc

或:

-NoNewWindow -PassThru可以解决问题