3

I am using SharePoint Designer 2013. I have a list of items and a form used to populate that list. When an item is created I have a workflow that is started that sends an approval request on that particular item. Once the item is approved/rejects then it moves on in the workflow to a condition. In the condition, if the item was approved I need it to run a power shell script that I have.

I have been looking all over for a solution to this without any luck. I have found this article that does what I need within a web part but I don't think that is what I need since I already have a form that is used for filling the list (unless I am misunderstanding how I could use a web part here). I have also taken a look at the workflow extension here but it is out of date.

The only other idea that I have seen is possible creating a web service to run the power shell script once the workflow calls an HTTP service action.

Has anyone had any luck performing the action that I am looking for?

1 Answer 1

4

In these cases I turn to the task scheduler which run every ten minute. It checks all the items in a list and a custom Boolean column called PowerShell. If it's set to no, I run the script and set the column to yes after its run.

$item["PowerShell"] = $true
$item.Update();
$web.Dispose();

See how in my own article Create subsite with PowerShell and Task Scheduler in SharePoint Server 2016

4
  • So you create a task on the SharePoint server that checks the list every 10 minutes to see if there are any items in the list that haven't been accounted for with your boolean value you mentioned? Do you need a subsite for that then like you have in your article?
    – sabo
    Jan 6, 2017 at 16:21
  • No. My article just takes it a step further. You can have anything you like in the PS-script that suits your need. Don't forget to run the script even if the Admin isn't signed in!
    – Benny Skogberg
    Jan 6, 2017 at 16:25
  • So basically I just need to create another column for the list that represents if that item has been taken care of already. Then I'll check in the PS script for each item if they have been taken care of and if not then I will use the logic that I need to run and then mark the item as finished so I don't run that item again. Sound right?
    – sabo
    Jan 6, 2017 at 17:09
  • That's right! Go ahead and good luck ;)
    – Benny Skogberg
    Jan 6, 2017 at 17:14

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.