我目前有一個腳本執行如下: 。\ script.ps1「param1」「param2」2> & 1 | tee -filePath buildlog.txt.ps1腳本中的PowerShell tee-object?
我無法找到一種方法來執行以下操作..記錄到腳本中封裝的控制檯和文件。 。 \ script.ps1「參數1」「參數2」
這是我在做嘗試:
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
啓動成績單不趕標準輸出非內置命令的,就像你說的;但是我看到它從*版本4.0開始捕獲Powershell命令的標準輸出(例如捕獲'Write-Out') – jpaugh