I'm trying to run a simple PS1 powershell script from the Task Scheduler. The task's Actions settings are
Program: powershell and
Add arguments: -executionpolicy bypass -file C:\Users\Robin\Documents\script.PS1.
The objective script.PS1 is accessed ok but a line within it (a call to another script:
Rscript Z:\rscript.R) fails with the message:
Fatal error: cannot open file Rscript Z:\rscript.R 'rscript.R': no such file or directory
If I run the same line manually in Powershell it works ok. Moreover the following runs fine as a Run command:
powershell -executionpolicy bypass -file C:\Users\Robin\Documents\script.PS1, which suggests the problem is in Task Scheduler. The task is set to run with highest privileges. I'm stumped.
Very grateful for assistance.