這是基於Write-Host
一個非常簡單的解決方法不存在這樣的問題。在會議開始時安裝/點源更換默認Write-Verbose
的:
function global:Write-Verbose
(
[string]
$Message
)
{
# check $VerbosePreference variable
if ($VerbosePreference -ne 'SilentlyContinue') {
# do this via Write-Host
Write-Host "VERBOSE: $Message" -ForegroundColor 'Yellow'
}
}
然後這個工程需要:
$VerbosePreference = 'Continue'
Start-Transcript -Path .\RunUnitTests.log
Write-Verbose ("verbose writes five million character lines and stuff. " * 20)
那就是:它考慮到$VerbosePreference
,將其寫入主機以黃色顯示,成績單輸出未被包裝,並且仍標記爲VERBOSE。
**********************
Windows PowerShell Transcript Start
Start time: 20101105055855
**********************
Transcript started, output file is .\RunUnitTests.log
VERBOSE: verbose writes ... <long line text> ... and stuff.
**********************
Windows PowerShell Transcript End
End time: 20101105055855
**********************
爲了防止纏繞在_all_詳細輸出,相關的問題,不只是從顯式調用'寫Verbose',請參閱[這個問題](http://stackoverflow.com/q/41504786/45375) 。 – mklement0 2017-01-08 13:02:50