How to get Powershell to complete a scheduled task?

I created a Powershell script and configured it to run in a .bat file. When I click on the .bat file, the Powershell script works like a champion. Then I installed the .bat file to run as a scheduled task. Again, he works like a champion when I click on him and launch him interactively. The problem is that it does not work when the task should start unattended in the evening.

Not sure if that matters, but I'm using Powershell v.1 on Windows 2003 Server 64.

Thanks in advance for your help.

============================================ Status of the scheduled task - "Could not start " Perhaps the failure was the wrong choice of words, because the task probably did not even start.

The task is configured to run as my user, and I am set as the local administrator in the field.

+4
source share
4 answers

Check if the security settings for the task are set. The scheduled task can be run under credentials that do not have access to the batch file.

When you add a new task, you are prompted for credentials

alt text

And you can check already created task credentials alt text

[UPDATE]

Scheduled task status: Failed to start. Perhaps the failure was the wrong choice of words, because the task probably did not even start.

Verify that the Task Scheduler service is running
alt text

+3
source

Is the task set to run with your user accounts or system? Check permissions on cmd.exe and powershell.exe.

Also, if you go to your scheduled tasks, you can do a “log view” in the advanced menu to check for error messages.

0
source

Just guessing, but could it be something related to the account / security context the script is running from? If it runs on a system account, this can be a problem. (I suspect that it just works in your user account.) Make sure that all of your path variables are set correctly when the script runs, for starters. Otherwise, could you provide more detailed information on how exactly this happens (for example, any error messages)?

0
source

Perhaps the current directory is not configured as you would expect when starting from the task manager. Try to run the bat file from the command line while you are not in the same directory as the file (and your .ps1 script).

Otherwise: check permissions.

0
source

All Articles