【问题标题】:Powershell output doesn't log properly when called from Task Scheduler从任务计划程序调用时,Powershell 输出无法正确记录
【发布时间】:2016-04-28 20:31:58
【问题描述】:

我需要记录我的 powershell 输出。我的 ps 文件是这样的:

#Set-ExecutionPolicy Unrestricted
$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
$date = (Get-Date).tostring("MMddyy HHmmss")
$filename = 'C:\apierror\logs\' + $date + '.txt'
Start-Transcript -path $filename -append

$python = "C:\Python34\python.exe"

$python_path = "C:\script.py"

cd (split-path $python_path)

& $python $python_path

Stop-Transcript

现在,当我直接从 powershell 运行此文件时,输出已正确记录。但是当我尝试从 taskscheduler 运行它时 - 只有一部分控制台输出存储在文件中。

有什么想法吗?

【问题讨论】:

    标签: windows powershell azure scheduled-tasks taskscheduler


    【解决方案1】:

    出于某种原因,使用脚本仅存储部分输出。我最终将日志直接使用到 python 文件中,而不是 powershell。似乎工作正常。

    【讨论】:

      猜你喜欢
      • 2020-11-13
      • 2012-11-26
      • 2017-07-02
      • 1970-01-01
      • 2017-06-22
      • 1970-01-01
      • 2012-08-30
      • 2017-08-22
      • 1970-01-01
      相关资源
      最近更新 更多