这是基于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