Start a SharePoint Designer Workflow on Multiple List Items
Introduction
This script can start a SharePoint Designer workflow on Multiple List Items in Microsoft SharePoint Server 2010.
Scenarios
In a real world, you may need to start a workflow on multiple list items. It will be a heavy task if you do it manually, so you are looking for a script to complete this task.
Script
This script contains the following advanced function:
You can use this script in the following way.
1. Open SharePoint 2010 Management Shell.
2. Run Import-Module cmdlet to import this module file.
Import-Module filepath\scriptname.psm1
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
PowerShell
Edit|Remove
powershell
foreach ($spListItem in $spListItems) {
$verboseMsg = $Messages.StartingWorkflow
$verboseMsg = $verboseMsg -f $WorkflowName,"$($spListItem.Title)(ID:$($spListItem.ID))"
$pscmdlet.WriteVerbose($verboseMsg)
Try
{
$spWFInstance = $spWeb.Site.WorkflowManager.StartWorkflow($spListItem,$spWorkFlow,$spWorkFlow.AssociationData,$true)
}
Catch
{
$pscmdlet.WriteError($_)
}
}
foreach ($spListItemin$spListItems) {
$verboseMsg = $Messages.StartingWorkflow
$verboseMsg = $verboseMsg-f $WorkflowName,"$($spListItem.Title)(ID:$($spListItem.ID))"$pscmdlet.WriteVerbose($verboseMsg)
Try
{
$spWFInstance = $spWeb.Site.WorkflowManager.StartWorkflow($spListItem,$spWorkFlow,$spWorkFlow.AssociationData,$true)
}
Catch
{
$pscmdlet.WriteError($_)
}
}
Examples
Example 1: How to display help about
Start-OSCSPWorkFlow.
To display help about
Get- OSCSPWorkflow,
please run this command.
Get-Help Get-OSCSPWorkflow -Full

Example
2: How to start workflow on
a list item with specified ID.
To start workflow on a list item with
specified ID, please run this command.
Start-OSCSPWorkFlow
-SiteURL "http://server_name/sites/sitename" -ListName "ListName" -WorkflowName "WorkflowName" -ItemId 53 -Verbose
Example
3: How to start workflow on
multiple list items.
To start workflow on multiple list items,
please run this command.
Start-OSCSPWorkFlow
-SiteURL "http://server_name/sites/sitename" -ListName "ListName" -WorkflowName "WorkflowName" -ItemId 53,55,58,62 -Verbose
Example
4: How to start workflow on
multiple list items that meet specified condition.
To start workflow on multiple list items
that meet specified condition, please run this command.
Start-OSCSPWorkFlow
-SiteURL "http://server_name/sites/sitename" -ListName "ListName" -WorkflowName "WorkflowName" -Query 'CAML Query' -Verbose
Note Please
enclose your query with single quote (') and don’t include the <Query></Query> tags.
Additional Resources