【问题标题】:Expand output of TF.exe results from PowerShell从 PowerShell 展开 TF.exe 结果的输出
【发布时间】:2012-01-03 22:48:46
【问题描述】:

我将批处理文件转换为查询 TFS 位置以返回最新变更集并将其显示在日志文件中的 PowerShell。这是该文件的编辑版本:

function Get-TfsChangeset([string]$TfsPath, [int]$PreviousDays = 1)
{
    $TfExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe"
    写入输出“正在获取 '$TfsPath' 的历史记录...”
    推送位置 $LocalPath
    $Today = 获取日期
    $Prior = $Today.AddDays(-$PreviousDays)
    & "$TfExePath" 历史 /recursive /format:brief /noprompt /version:D$($Prior.Month)/$($Prior.Day)/$($Prior.Year)~D$($Today.Month) /$($Today.Day)/$($Today.Year) $TfsPath
    流行位置
    写输出"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 完成~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~`n"
}

$ReportLogPath = "C:\temp\TfsHistoryReport.log"

Get-TfsChangeset "$/Some/Branch" > $ReportLogPath

写入输出“正在打开日志 '$ReportLogPath'...”
启动进程记事本$ReportLogPath

但是,TF.EXE GET 返回的文本被截断了:

=========================== 开始时间:11/22/2011 09:43:31 ======== ==================

获取“$/Some/Branch”的历史记录...
变更集用户日期注释
--------- ------------- ---------- ------------------ --------------------------
12345 ...adis 11/21/2011 标签中的代码无效。需要解决这个问题
12346 joe.blow 2011 年 11 月 21 日错误 #1:没有任何工作,所以正确修复它 n
12347 john.smith 2011 年 11 月 21 日错误 #2:我不喜欢新的 UI 更改,所以 f
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~

=========================== 完成时间:11/22/2011 09:43:42 =========== =============

我可以通过像这样设置控制台列宽来在批处理文件中绕过它:

mode con cols=250

但我不确定如何在 PowerShell 中执行此操作。

有什么想法吗?

【问题讨论】:

  • mode con cols=250 在我的 powershell 控制台中做同样的事情..
  • 我无法说出那句话,我不得不做一些额外的事情,但这就是答案。 $originalBufferSize = $Host.UI.RawUI.BufferSize $newBufferSize = new-object System.Management.Automation.Host.Size 250,$originalBufferSize.Height $Host.UI.RawUI.BufferSize = $newBufferSize # TF.EXE 东西在这里 $ Host.UI.RawUI.BufferSize = $originalBufferSize
  • 你试过 BufferSize 属性了吗?

标签: powershell tfs


【解决方案1】:

来自 OP 的评论:

我无法输入mode con cols=250,我不得不做一些额外的事情,但这就是答案。

$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 output column width

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-24
    • 1970-01-01
    • 2021-07-04
    相关资源
    最近更新 更多