我目前有一个执行如下的脚本: .\script.ps1 “param1” “param2” 2>&1 | tee -filePath buildlog.txt
我找不到执行以下操作的方法.. 记录到脚本中封装的控制台和文件。.\script.ps1 “param1” “param2”</p>
这是我的尝试:
powershelltest.ps1
param([string]$paramOne, [string]$paramTwo)
function DoWork()
{
Write-Host '3'
}
function WriteLogFile()
{
DoWork
# The following would not be captured by Start-Transcript & Stop-Transcript
# program.exe ....
Write-Host '4'
}
function CollectorFunction()
{
Write-Host '2'
WriteLogFile;
Write-Host '5'
}
Write-Host '1'
CollectorFunction 2>&1 | tee -filePath c:\log.foo