Log file not being generated while running a script via Windows Task Scheduler
问题 Log file not being generated while running a PowerShell script via Windows Task Scheduler. Code as below: function check-cert { $cmd = "Certutil -crl" Invoke-Expression $cmd if($LASTEXITCODE -eq '0') { Write-Output $LASTEXITCODE } else { $output = $LASTEXITCODE $date = (Get-Date).ToString() $result = $date + " " + $output $result | Out-File "C:\users\admin\Documents\Powershell\crllog.txt" -Append Write-Host "crl failed to publish" } } check-cert Could you please help me in getting the log