这是https://serverfault.com/questions/102098/powershell-script-showing-commands-run的副本,我想在这里问这个问题会更合适。
我在玩PowerShell脚本,它们运行得很好。但是,我想知道是否有任何方法也显示所有运行的命令,就像你自己手动键入它们一样。这类似于批处理文件中的“echo on”。我查看了PowerShell命令行参数和cmdlet,但我没有发现任何明显的东西。
这是https://serverfault.com/questions/102098/powershell-script-showing-commands-run的副本,我想在这里问这个问题会更合适。
我在玩PowerShell脚本,它们运行得很好。但是,我想知道是否有任何方法也显示所有运行的命令,就像你自己手动键入它们一样。这类似于批处理文件中的“echo on”。我查看了PowerShell命令行参数和cmdlet,但我没有发现任何明显的东西。
4条答案
按热度按时间zlhcx6iw1#
更多信息:https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/set-psdebug?view=powershell-6
9cbw7uwe2#
Start-Transcript没有捕捉到任何exe输出。这对我来说是一个显示障碍。我不想这么说,但我发现的最好的方法是:
这捕获了所有AFAICT。
rta7y2nd3#
我在所需命令中添加了-verbose。
57hvy0tb4#
注#1:它只记录写入主控制台输出流的内容,而不是警告/错误/调试。
注意#2:如果需要记录本机控制台应用程序,you'll need a slight workaround