1

I have a SharePoint List. I update each item in the list every morning using the following PowerShell script (because I need a calculated column to update daily):

Microsoft.SharePoint.PowerShell

$spWeb = Get-SPWeb -Identity https://mysite/sites/sitename
$spList = $spWeb.Lists["MyListName"]
$spList.Items | ForEach-Object { $_.Update() }

I also have a Sharepoint Designer Workflow on this list that is set to run when any item is changed. So the expectation is that every morning, when the Powershell script runs, each item is updated, then the workflow runs.

When I run the workflow manually on an item it runs without problems, however when it runs based on the update it results in a Canceled status.

Any ideas what the difference might be - or other suggestions on how to get the workflow to run daily?

  • Can you try with introducing some pause in the for-each loop before updating the list item & see if it works? – Muhammad Usman Apr 14 '16 at 17:15
2

Check that the powershell isn't running as a service account. Similar question answered here:

Creating item in list using workflow doesn't trigger item created workflow

  • Sorry for my ignorance, but how would I check that? I have the powershell script set up in the Task Scheduler and it has the Author as my farm account. It is set to run with highest privileges. Should I change the Author to something else and if so, how do I do that? – Maureen Apr 14 '16 at 18:50
  • Yes, if the Farm account is used to run the powershell, then that is a system account (according to SharePoint). By default, system accounts do not initiate workflows, which is what I am guessing your issue is. If you change it to another account (with enough privileges to both run the powershell statements and modify the list) then the workflows will kick off after any updates. – Kolten Apr 15 '16 at 17:31
  • How do I check if an account has "enough privileges to run the powershell statements". – Maureen May 4 '16 at 18:19
  • The farm account has enough privileges – Kolten May 4 '16 at 18:35
1

Complementing Kolten's answer:

And if you really need to run it as a System Account, you can also start workflows with some powershell:

Nice solution

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.