powershell - 删除 Windows PowerShell 转录起始 header

标签 powershell

使用以下内容设置日志记录时:

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
Start-Transcript -path C:\output.txt

始终添加以下 header - 有什么方法可以阻止添加此 header 吗?

**********************
Windows PowerShell transcript start
Start time: 20130413235532
Username  : computer\administrator 
Machine   : wsa (Microsoft Windows NT 6.2.9200.0) 
**********************
Transcript started, output file is C:\output.txt

最佳答案

没有办法阻止 Start-Transcript 输出这些 header 。另请记住,Start-Transcript 不会记录 EXE 的输出。如果您需要记录脚本输出并且使用的是 PowerShell v3,那么最好的选择是这样做:

PS> .\myscript.ps1 *> myscript.log

这将记录除 Write-Host 输出之外的所有内容。

关于powershell - 删除 Windows PowerShell 转录起始 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15992592/

相关文章:

Powershell - 如何将命令行参数传递给模块中的函数?

authentication - Powershell中WebClient的身份验证错误

powershell - 检测以相同名称运行的进程数

powershell - Resolve-DnsName - 特定端口上的服务器

powershell - 如何更新脚本中的变量?

xml - 将数据对象 XML 与 Powershell 结合使用

powershell - powershell:从字符串末尾删除文本

sharepoint - 如何从 powershell 发布/批准 SharePoint 2010 中的页面

powershell - 在Powershell下在后台运行docker

powershell - Azure 用户删除错误