Skip Ribbon Commands
Skip to main content

Erin Glenn's Blog

:

Erin Glenn's Blog > Posts > Run a Workflow on a List Via Powershell
November 22
Run a Workflow on a List Via Powershell

Use this Powershell script to run a specific workflow on a specific list:

# URL of the Site

$web = Get-SPWeb -Identity "https://sharepointsrv/site1"

$manager = $web.Site.WorkFlowManager

# Name of the list

$list = $web.Lists["Shared Documents"]

# Name of the Workflow

$assoc = $list.WorkflowAssociations.GetAssociationByName("On Item Created","en-US")

$data = $assoc.AssociationData

$items = $list.Items

foreach($item in $items)

 {

 $wf = $manager.StartWorkFlow($item,$assoc,$data,$true)

 }

$manager.Dispose()

$web.Dispose()

#

I used to have to make a change to every list item (using Datasheet view) to force the "on update run the workflow".  However, sometimes this doesn't work if the item doesn't have all required fields completed. 

​Thanks to this blog post​ for this script. It worked like a charm for me!

Comments

There are no comments for this post.