How can I redirect PowerShell output when run from Task Scheduler?

前端 未结 9 949
我在风中等你
我在风中等你 2020-12-13 12:35

When running a simple PowerShell script from Task Scheduler, I would like to redirect the output to a file.

There is a long thread about this very topic here, yet i

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 13:17

    Here is the command that worked for me. I didn't like the idea of redirecting the output in the script, since it would make it difficult to run manually.

    powershell -windowstyle minimized -c "powershell -c .\myscript.ps1 -verbose >> \\server\myscript.log 2>&1"
    

提交回复
热议问题