0

We are using SP2010. I have prepared a PowerShell script to trigger particular workflow on particular object. Here is the script:

$web = Get-SPWeb "http://url/";
$list = $web.Lists["My list"];
$manager=$web.Site.WorkFlowManager
$association = $list.WorkFlowAssociations |Where { $_.Name -eq "Name of Workflow"}
$data = $association.AssociationData
$data=$association.AssociationData
$item = $list.GetItemById(1234)
$wf=$manager.StartWorkFlow($item,$association,$data,$true)

We have a dev and test sharepoint environment. Our dev environment is a single server installation. The script above can start the workflow but immediately turn to "Failed on start" error (and stopped). By running same script on our test environment, it works perfect.

I checked the ULS log, it indicate my web.config have problem.

RunWorkflow: Microsoft.SharePoint.SPException: An error occurred creating the configuration section handler for System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes: Could not find file 'C:\Users\devserver1\AppData\Local\Temp\ottgdnfv.dll'. (C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config line 683)

I have compared the web.config file between two environment and they are the same.

The same workflow can be triggered manually (on both environment) without problem.

6
  • are you by any chance running this command with System Account ? It wont work with that. Apr 18, 2018 at 8:32
  • I have tried change the script to impersonate a site collection admin and then a normal user. The workflow initiator changed to new person but still same error.
    – Mark L
    Apr 18, 2018 at 9:07
  • Oh I love it how after hours of googling I always find that one single SO post that exactyl matches my problem ... with NO ANSWER.
    – ben
    Nov 9, 2021 at 14:32
  • 1
    And here it comes: My account was assigned a global permission policy with a checkmark at "operates as system". After deleting the policy my account did no longer "operate as system" and it worked. Thanks to Eric Fang: fangdahai.blogspot.com/2014/07/…
    – ben
    Nov 9, 2021 at 14:59
  • @ben Although it is 3 years ago and I am no longer work in that environment, I believe it is the solution.
    – Mark L
    Nov 10, 2021 at 1:14

1 Answer 1

0

If you're running the PowerShell session on the SharePoint server, make sure to launch the PowerShell app as admin.

Your Answer

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

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