Sharepoint Workflow "Failed on Start" only when powershell import script is called from task scheduler

Posted by Matt Keller on Server Fault See other posts from Server Fault or by Matt Keller
Published on 2013-06-25T21:22:30Z Indexed on 2013/06/25 22:22 UTC
Read the original article Hit count: 409

I created a simple PowerShell script that takes an XML file in a local directory on our sharepoint server and imports it into a specific SharePoint form library. (Content management enabled library if that makes any difference) This script works flawlessly if i run it from the PowerShell command line manually. I call it like such: ".\script_name.ps1". It completes without error and the item is imported into the form library successfully. The workflow begins on the item and everything is happy dandy.

However, i run into issues when i setup a scheduled task using Windows Server 2008 R2's task manager. The task runs the script without error and it does actually import the XML into the form library. I looks perfectly normal just as if i had run the script manually. However, after about 10 or 20 minutes the workflow status for that item changes from "In progress" to "Failed on Start (Retrying)".

The scheduled task in question is a basic task and has only one action. (Start a program) The "program/script" box is set to "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" and the "Add arguments" box is set to the path of the actual ps1 script. (C:\scripts\sharepoint_import.ps1) I've tried running the task as various users. I've also tried with and without the "Run with highest privileges" check box. Nothing seems to work.

For reference, here is the script i am using to import items into the form library.

© Server Fault or respective owner

Related posts about windows-server-2008-r2

Related posts about powershell