从 PowerShell 扩展 TF.exe 结果的输出 [英] Expand output of TF.exe results from PowerShell
本文介绍了从 PowerShell 扩展 TF.exe 结果的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将一个批处理文件转换为 PowerShell,该文件查询 TFS 位置以返回最新的变更集并将其显示在日志文件中.这是该文件的编辑版本:
I converted a batch file to PowerShell that queried a TFS location to return the latest changesets and display them in a log file. This is an edited version of that file:
function Get-TfsChangeset([string]$TfsPath, [int]$PreviousDays = 1)
{
$TfExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe"
Write-Output "Getting history for '$TfsPath'..."
Push-Location $LocalPath
$Today = Get-Date
$Prior = $Today.AddDays(-$PreviousDays)
& "$TfExePath" history /recursive /format:brief /noprompt /version:D$($Prior.Month)/$($Prior.Day)/$($Prior.Year)~D$($Today.Month)/$($Today.Day)/$($Today.Year) $TfsPath
Pop-Location
Write-Output "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Done ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`n"
}
$ReportLogPath = "C:\temp\TfsHistoryReport.log"
Get-TfsChangeset "$/Some/Branch" > $ReportLogPath
Write-Output "Opening log '$ReportLogPath'..."
Start-Process notepad $ReportLogPath
但是TF.EXE GET返回的文本被截断了:
However, the text returned from TF.EXE GET is cut off:
=========================== Started: 11/22/2011 09:43:31 =========================
Getting history for '$/Some/Branch'...
Changeset User Date Comment
--------- ------------- ---------- --------------------------------------------
12345 ...adis 11/21/2011 Invalid code in the tags. Need to fix this
12346 joe.blow 11/21/2011 Bug#1: Nothing is working so fix it right n
12347 john.smith 11/21/2011 Bug#2: I don't like the new UI changes so f
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Done ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=========================== Completed: 11/22/2011 09:43:42 =======================
通过将控制台列设置为宽,我能够在批处理文件中绕过它:
I was able to get around it in the batch file by setting the console columns wide like this:
mode con cols=250
但我不确定如何在 PowerShell 中执行此操作.
But I'm not sure how to do that in PowerShell.
有什么想法吗?
推荐答案
来自 OP 的评论:
我无法输入 mode con cols=250
,我不得不做一些额外的工作,但这就是答案.
I couldn't put mode con cols=250
in, I had to do a little extra, but that was the answer.
$oldBufferSize = $Host.UI.RawUI.BufferSize
$newBufferSize = New-Object Management.Automation.Host.Size 250,$oldBufferSize.Height
$Host.UI.RawUI.BufferSize = $newBufferSize
# TF.EXE stuff here
$Host.UI.RawUI.BufferSize = $oldBufferSize
这篇关于从 PowerShell 扩展 TF.exe 结果的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文