3

I have a powershell script that I want to run as a schedule job.

The script runs great when I execute it manually, but when I run the schedule task, the job fails with the message "could not start"

Schedule job setup:

Run: powershell -command "& 'ScriptName.ps1'" Start in: Run as:

This is scheduled on a Windows Server 2003 and is running powershell 1.

  • what is the ampersand for? When I want to debug these, I configure the job to interact with the desktop and start a cmd shell. From there I run the command-line and fix things until it works. The idea being that you can sure permissions and config issues interactively first. – uSlackr Jun 15 '12 at 16:42
1
  1. try to use the full path of ScriptName.ps1

  2. does the script depend on anything in your $Profile? if it does, it may not be loaded when you run as a schedule job, so make sure that you load the module or set up env variables needed.

  • when I tried using the full path, same error. – Scott Jun 19 '12 at 13:19
  • I ended up needing to use the full path fro both the script and powershell itself. Apparently powershell wasn't in PATH – Scott Jun 21 '12 at 15:37
  • @Scott can you please explain bit more in detail what you did. – Mowgli Mar 15 '13 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.