使用EncodedCommand输出到标准错误的启动过程

时间:2018-08-01 13:16:02

标签: powershell

以下脚本演示了从PowerShell v4迁移到v5.1后遇到的问题。我广泛使用Start-Process将StandardError重定向到文件,如果该文件在执行后包含数据,我可以读取该文件以查看问题所在。

但是,对于v5.1,当启动的PowerShell进程启动时,它利用错误流上的进度输出,因此将其重定向到错误文件。在以前的PowerShell版本中,没有发生这种情况,如果我使用 Command 而不是 EncodedCommand ,它将按预期工作。

我相信这是一个错误,但是如果有人可以确认或建议解决方法,它将很有用?

以下脚本的输出如下:

PowerShell v4

  

没有错误
  你好,世界!

PowerShell v5.1

  

警告:

     

SourceId记录

     
Sub sum_squares()
Dim total As Integer
Dim c As Range
Dim d As Range

'set d equal to column from active cell down to last non-empty'
d = Range(ActiveCell, ActiveCell.endxldown)
total = 0
For Each c In d
   total = total + c.Value ^ 2
Next c

End Sub
     

你好,世界!

     

你好,世界!

演示脚本

注意:这将创建2个临时文件,它们都将在末尾删除。

   1 parent = -1 id = 0 act = Preparing modules for first use. stat =   cur =  pct = -1 sec = -1 type = Completed

0 个答案:

没有答案
相关问题