我如何只能从 powershell 中的此输出中选择第一行(名称)? 输出
代码是这样的:
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;
我只想拥有此列表中的名称。
谢谢!
我如何只能从 powershell 中的此输出中选择第一行(名称)? 输出
代码是这样的:
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;
我只想拥有此列表中的名称。
谢谢!
管道输出到选择对象:
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