PowerShell“;“回音”;
这是一个复制品。我认为在这里问这个问题更合适 我正在玩PowerShell脚本,它们工作得很好。但是,我想知道是否有任何方法也可以显示所有运行的命令,就像您自己手动键入命令一样。这类似于批处理文件中的“echo on”。我查看了PowerShell命令行参数和cmdlet,但没有发现任何明显的问题。PowerShell“;“回音”;,powershell,command,echo,Powershell,Command,Echo,这是一个复制品。我认为在这里问这个问题更合适 我正在玩PowerShell脚本,它们工作得很好。但是,我想知道是否有任何方法也可以显示所有运行的命令,就像您自己手动键入命令一样。这类似于批处理文件中的“echo on”。我查看了PowerShell命令行参数和cmdlet,但没有发现任何明显的问题。C:\workspace\silverlight>start-transcript-? C:\workspaces\silverlight> start-transcript -? NAME
C:\workspace\silverlight>start-transcript-?
C:\workspaces\silverlight> start-transcript -?
NAME
Start-Transcript
SYNOPSIS
Creates a record of all or part of a Windows PowerShell session in a text file.
SYNTAX
Start-Transcript [[-Path] <string>] [-Append] [-Force] [-NoClobber] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The Start-Transcript cmdlet creates a record of all or part of a Windows PowerShell session in a text file. The transcript includes all command that the user
types and all output that appears on the console.
RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113408
Stop-Transcript
REMARKS
To see the examples, type: "get-help Start-Transcript -examples".
For more information, type: "get-help Start-Transcript -detailed".
For technical information, type: "get-help Start-Transcript -full".
名称
开始记录
提要
在文本文件中创建Windows PowerShell会话的全部或部分记录。
语法
开始转录本[[-Path]][-Append][-Force][-NoClobber][-Confirm][-WhatIf][]
描述
Start-Transcript cmdlet在文本文件中创建Windows PowerShell会话的全部或部分记录。该成绩单包括用户输入的所有命令
类型和控制台上显示的所有输出。
相关链接
网上版本:http://go.microsoft.com/fwlink/?LinkID=113408
停止记录
评论
要查看示例,请键入:“get help Start Transcript-examples”。
有关详细信息,请键入:“获取帮助开始记录-详细信息”。
有关技术信息,请键入:“获取帮助开始记录-完整”。
注意#1:它只记录写入主控制台输出流的内容,而不记录警告/错误/调试
注意#2:如果需要录制本机控制台应用程序,Start Transcript不会捕获任何exe输出。对我来说,这是一场精彩的比赛。我不想这么说,但我发现最好的方法是:
cmd /c powershell.exe -file c:\users\hillr\foo.ps1 > foo.log
这捕获了AFAICT中的所有内容。我在所需命令中添加了-verbose。例如
Copy-Item c:\xxx d:\xxx -verbose
- 0:关闭脚本跟踪
- 1:在脚本行运行时跟踪它们李>
- 2:跟踪脚本行,变量 赋值、函数调用和脚本
更多信息:前几天刚看到这个。这并不理想,但如果您将exe输出管道设置为默认值,它将被捕获。问题是,无论您在哪里调用exe,您都必须将其散布到脚本中。如果您调用其他人调用EXE的脚本,则必须修改他们的脚本。所以,是的,不理想。:-)啊,安迪的链接可能解释了为什么我在start成绩单上看的不多。明天,我将继续讨论基思的想法(下面是理查德的)。这就是那篇文章的内容:
Start-Transcript;ipconfig |退出默认;Stop Transcript
但这不包括错误流,因为:…2>&1>>file.log
我也对其进行了修改,但Start Transcript会捕获其他流(进度流除外)。它不会捕获EXE输出,除非你使用Andy提到的Out默认技巧,无论你在哪里使用EXE。我是一名程序员,我喜欢PowerShell,但我认为这是一个非编程问题,属于ServerFault。我是一名程序员,我喜欢PowerShell,我认为这个问题在stackoverflow就在家里。我使用PowerShell作为编程工具包的一部分。
Set-PSDebug -Trace 1