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? – eirikb Nov 21 '14 at 6:50
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. – Melikoth Apr 10 '15 at 22:12
  • Its always a nice feeling to help out someone... :) – Amit Tyagi Apr 11 '15 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, privacy policy and cookie policy

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