仅从输出中选择第一行

时间:2016-03-30 12:30:01

标签: powershell psake

我怎样才能在powershell中从此输出中选择第一行(名称)? 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;

我想只列出此列表中的名字。

谢谢!

1 个答案:

答案 0 :(得分:0)

将输出管道输出到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