Select 只有输出的第一行

Select only first row from output

我如何才能在 powershell 中仅 select 此输出的第一行(名称)? Output

代码是这个:

1. Import-Module "C:\CMI\Entwicklung\MetaTool\packages\psake.4.5.0\tools\psake.psm1"
2. invoke-psake -buildFile "C:\CMI\Entwicklung\MetaTool\Build\default.ps1" -docs;

我只想要这个列表中的名字。

谢谢!

将输出通过管道传输到 select-object:

Import-Module "C:\CMI\Entwicklung\MetaTool\packages\psake.4.5.0\tools\psake.psm1"
invoke-psake -buildFile "C:\CMI\Entwicklung\MetaTool\Build\default.ps1" -docs | select Name

编辑

 $a = Invoke-psake default.ps1

 $a
 psake version 4.6.0
 Copyright (c) 2010-2014 James Kovacs & Contributors

 Executing Clean
 Executed Clean!
 Executing Compile
 Executed Compile!
 Executing Test
 Executed Test!

 Build Succeeded!

 ----------------------------------------------------------------------
 Build Time Report
 ----------------------------------------------------------------------
 Name    Duration        
 ----    --------        
 Clean   00:00:00.0193100
 Compile 00:00:00.0148280
 Test    00:00:00.0169533
 Total:  00:00:00.1112917


$b=($a | select-string ":").count-1; ($a | Select-String ":")  -replace "\d{2}\:\d{2}:\d{2}.\d{7}"| select -First $b
Clean   
Compile 
Test