更新时间:2023-12-06 13:03:34
把这个放在文件的顶部:
Put this at the top of your file:
$Logfile = "D:\Apps\Logs\$(gc env:computername).log"
Function LogWrite
{
Param ([string]$logstring)
Add-content $Logfile -value $logstring
}
然后将您的 Write-host
调用替换为 LogWrite
.
Then replace your Write-host
calls with LogWrite
.