Task Scheduler executes script but does not output to log file

Viewed 228

I am running into the following issue :

I have a task scheduler job running across a number of Azure VMs, it is scheduled to run at ~11pm every wednesday.

From what I can see the script executes the required change, however it does not generate the log output file

enter image description here

the argument I use is the following:

-F C:\Users\Admin\Desktop\scripts\automatexml_weu.ps1 -Verbose > C:\Users\Admin\Desktop\scripts\xml_script_logs\xml_script_output_$(Get-Date -format "yyyyMMdd").log

But the log file is never generated.

If I run the above command outside of Task Scheduler it works with no issues

Anyone have any ideas where I am going wrong?

Thanks in advance

1 Answers

Unfortunately it doesnt seem possible to do it this way through Task Scheduler.

"The scheduled task cannot redirect that way. You will have to redirect to a file inside of the PowerShell script. It is PowerShell that supports that redirection." - technet

Related