Powershell 仅从输出中选择第一行
如何在powershell中仅从该输出中选择第一行(名称)? 代码如下:Powershell 仅从输出中选择第一行,powershell,psake,Powershell,Psake,如何在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
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
将输出分配给var并获取ist类型:
$a=invoke$a、 gettype()
这将让您了解什么是数据类型,以及我们是否可以使用select语句。以下是数组中每个值的类型:1+2=Microsoft.PowerShell.Commands.Internal.Format.StartData 3-9=Microsoft.PowerShell.Commands.Internal.Format.PacketInfoData是否有一种简单的方法可以让此模块在自己的环境中运行,而无需设置一些构建过程?如果有一个包含“Name”的数组,您应该使用$Array | select Name访问它。可能,他们正在使用write-Output语句,但这在函数中并不好。我将在wiki中再次查看。。。我尝试了很多(选择、分割、格式化等),但似乎没有任何效果。你也可以查看函数,它们返回什么类型等。但我认为,它是一个更大的函数,调用其他函数等。