Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Does anyone know the correct way to assign a Powershell script as a scheduled task?

I have the below syntax (where X:/ is another drive mapped as a share).

enter image description here

share|improve this question

3 Answers 3

I've had problems when running Powershell scripts using the Nagios windows client, NSClient++. The solution for me was to run the command as follows...

cmd /c echo "X:\Technet Scripts\updateWindows.ps1" | powershell.exe -Command -

I'm not saying this is the best or correct way for you to run your script from a scheduled task, but it may get it working for you.

share|improve this answer

I always just put 'powershell.exe' in the 'Program/script:' textbox and the full path to the script in 'Add arguments (optional)'. That always works for me.

I would also use a UNC name instead of a mapped drive letter. Who know whether the user who runs the task knows about that drive letter.

share|improve this answer

What you have seems to be correct. Is it not running at the scheduled time, or are you getting an error?

The "-file" parameter isn't really required since you're not running the script in an existing session, but it should still work fine.

You can read more about running powershell scripts here: http://technet.microsoft.com/en-us/library/ee176949.aspx#EBAA

share|improve this answer

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.