且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 2005 SQL Server 中从 SQL 代理作业运行脚本时,Powershell Transcript 为空

更新时间:2022-05-20 22:32:14

我仍然不确定为什么 Powershell Transcript 为空,但我们找到了解决方法.在 SQL 作业的 CmdExec 步骤下,有一个将输出捕获到文件的高级选项,该选项与将输出附加到现有文件"选项相结合,并使用 Logfile.rtf 扩展名与 Powershell 脚本大致相同.这样,从 Powershell 脚本打印到主机的任何内容(包括通过管道传输到| out-host"的本机控制台可执行文件)都将被记录在日志文件中.

I am still not sure why the Powershell Transcript is empty, but we found a workaround. Under the CmdExec step of the SQL Job there is an advance option to capture the output to a file, which combined with the "Append output to existing file" option and using a Logfile.rtf extension is about the same as the Powershell transcript. This way anything that gets printed to the host from the Powershell script (including native console executables piped to "| out-host") will be captured in the log file.