Select only first row from output

2.2k Views Asked by At

How can i only select the first row (Name) from this Output in powershell? Output

The Code is this one:

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;

I want to have only the names from this list.

Thank you!

1

There are 1 best solutions below

8
Martin On BEST ANSWER

Pipe the Output to 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

Edit

 $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