问题描述
所以我有下面的循环,最后一项:日志写入只是没有开始。
Foreach ($Manager in $Managers) {
$time = (Get-Date).ToString('T')
New-bhReportToGroup
Get-bhDReports
Set-bhRTGmembers
Log-Write -LogPath $sLogFile -LineValue "========================[ $time ]==============================="
}
我没有把所有代码都塞满,因为我打赌这并不重要。但是我在所有工作的各种功能中有多个 Log-Write 调用。目标是在日志文件中的每个循环迭代之间引入一个分隔符。
这很好,$Global:DebugPreference
设置为继续,但日志文件中没有任何内容。
谢谢!
编辑
日志写入函数执行此操作:
Function Log-Write {
[CmdletBinding(SupportsShouldProcess)]
Param ([Parameter(Mandatory=$true)][string]$LogPath,[Parameter(Mandatory=$true)][string]$LineValue)
Process{
Add-Content -Path $LogPath -Value $LineValue
#Write to screen for debug mode
Write-Debug $LineValue
}
}