Hi,

I have set up a scheduled task to run a powershell script Test.ps1. This script is meant to run three other powershell Scripts one by one in a powershell script e.g

‘C:\Users\WP\Desktop\Scripts\1.ps1’

‘C:\Users\WP\Desktop\Scripts\2.ps1’

‘C:\Users\WP\Desktop\Scripts\3.ps1’

I have scheduled the task as under:

Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Add argruments: -noprofile -executionpolicy unrestricted -noninteractive -file “'C:\Users\WP\Desktop\Scripts\Test.ps1”

The task runs without error, return 0. But the ps script wasn’t executed. It works fine when I run it manually. Any inputs?

2 Spice ups

First question, does the account used to run the scheduled task have access to the path C:\Users\WP\Scripts?

The problem lies with the -file parameter. What you need to do is just the following: -File Test.ps1 and then in the scheduled task, change the Start In to C:\Users\WP\Desktop\Scripts. For whatever reason powershell does not accept full paths in File, just a singular file. Example.png

This is factually incorrect.
I run numerous scheduled tasks using -file \server\share\folder\filename.ps1 and have no issues.
I don’t use the Start In option.

Have you tested without some of the configuration options?
What happens if you manually execute the scheduled task without the -noprofile and -noninteractive parameters?