我试图从另一个Powershell函数调用Powershell函数。我调用的函数有很多详细的输出,我需要将它们捕获到一个文件中。由于我多次调用所述函数,我需要将详细输出附加到文件的末尾。
我尝试了以下
Invoke-TeardownWorkflow -WorkflowID $i -PostTeardownAction=@{$IPList[$i]="Reconnect-PrimaryNetwork"} 9 >>C:\TeardownLog.log
但是,代码没有按预期工作并且不断重复
A positional parameter cannot be found that accepts argument '9'.
该功能是源控制的(因此,我无法触摸该功能)。这些函数也是PSM1
个文件的一部分。 Teardown.log文件在执行上述代码之前有一些条目。
答案 0 :(得分:1)
您可以使用4>
Invoke-TeardownWorkflow -WorkflowID $i -PostTeardownAction=@{$IPList[$i]="Reconnect-PrimaryNetwork"} 4>C:\TeardownLog.log
有关重定向的更多信息here,这是一个摘录:
4> Sends verbose output to Import-Module * -Verbose 4> Verbose.txt
the specified file.
4>> Appends verbose output Import-Module * -Verbose 4>> Save-Verbose.txt
to the contents of the
specified file.