Powershell:如何从主机捕获输出 [英] Powershell: How to capture output from the host

查看:72
本文介绍了Powershell:如何从主机捕获输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 powershell 自动执行一些与 TFS 中的签出/合并相关的任务.当我打电话

I am using powershell to automate some tasks related to checking out/merging in TFS. When I call

tf get * /recurse

我得到了一堆关于正在被检出的文件的滚动数据.这个命令生成的最后一行(假设它成功)是一个告诉签入号的行.我想将其解析出来,以便稍后在我的脚本中使用.

I get a bunch of data scrolling by about the files that are getting checked out. The last line generated by this command (assuming its success) is one telling the checkin number. I would like to parse this out so it can be used later on in my script.

我知道我可以做类似的事情

I know that I can do something like

$getOutput = tf get * /recurse

但随后输出被完全抑制,我希望实时滚动该命令的输出.我基本上想获取刚刚发送到输出缓冲区的所有内容.

but then the output is suppressed entirely and I want the output of that command to be scrolled in realtime. I would basically like to grab everything that just got sent to the output buffer.

推荐答案

试试这个:

tf get */recurse |tee-Object -Variable getOutput

tf get * /recurse | tee-Object -Variable getOutput

这篇关于Powershell:如何从主机捕获输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆