Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
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 Answer 1

up vote 0 down vote accepted
  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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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