首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PowerShell "echo on“

PowerShell "echo on“
EN

Stack Overflow用户
提问于 2010-01-14 20:28:40
回答 4查看 39.2K关注 0票数 56

这是https://serverfault.com/questions/102098/powershell-script-showing-commands-run的复制品。我认为在这里问这个问题会更合适。

我正在尝试使用PowerShell脚本,它们工作得很好。但是,我想知道是否有任何方法可以显示所有运行的命令,就像您手动键入它们一样。这类似于批处理文件中的"echo on“。我查看了PowerShell命令行参数和cmdlet,但没有发现任何明显的东西。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-01-14 23:16:09

Start-Transcript不能捕获任何exe输出。对我来说,这是一场精彩的表演。我不想这么说,但我找到的最好的方法是:

代码语言:javascript
复制
cmd /c powershell.exe -file c:\users\hillr\foo.ps1 > foo.log

这将捕获AFAICT的所有内容。

票数 12
EN

Stack Overflow用户

发布于 2018-04-04 17:30:05

代码语言:javascript
复制
Set-PSDebug -Trace 1

  • 0:关闭脚本跟踪。
  • 1:跟踪运行的脚本行。
  • 2:跟踪脚本行、变量赋值、函数调用和脚本。

有关更多信息,请访问:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/set-psdebug?view=powershell-6

票数 55
EN

Stack Overflow用户

发布于 2010-01-14 23:04:06

代码语言:javascript
复制
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".

注意#1:它只记录写入到主控制台输出流中的内容,而不是警告/错误/调试。

注意#2:如果您需要记录本机控制台应用程序,you'll need a slight workaround

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2063995

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档