1

I have a Pscript for clearing and repopulating a Sharepoint 2010 list. It works fine when run manually. I set it to run as a scheduled task, and the history shows it as running successfully, but the content of the list doesn't appear to change. At least, the Modified Date for the list doesn't change.

Here's the command:

  powershell –file "C:\Pscripts\MyScript.ps1
1
  • Did you try to check off the script to run with highest privileges? Commented Nov 21, 2014 at 6:50

2 Answers 2

2

Please ensure you are following the steps mentioned here for scheduling your task.

Looking at history of the scheduled task doesn't ensures that the powershell has executed successfully. Even if the powershell is returning an error, the scheduler history will show as "running successfuly".

2
  • This worked for me, I was trying to specify the full path to my script, but I needed to use it with the 'start in' option as described. Commented Apr 10, 2015 at 22:12
  • Its always a nice feeling to help out someone... :) Commented Apr 11, 2015 at 0:20
0

This is what we use. Under the task options for Action choose "Start a program".

Program/Script:

"%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"

Add Arguments:

-command "& 'C:\Pscripts\MyScript.ps1'"

You could also try to log something in your script so that you can see if it is being run or failing etc.

I use this function to Log stuff being run via the task manager.

function Log($msg)
{
    $msg
    $msg | Out-File $TranscriptFileName -Append
}

Usage:
Log "Starting Powershell Script"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.