Start a Sharepoint Workflow using Powershell

…this post was published on 2014 August 12.

To use Powershell which will start a workflow attached to s specific library/list I propose you this code

$web = Get-SPWeb -Identity “http://XXXXXXXXXX/sites/test”

$manager = $web.Site.WorkFlowManager

# get the ame of the list
$list = $web.Lists[“Shared Documents”]

# Name of the Workflow
$assoc = $list.WorkflowAssociations | Where-Object {$_.Name -eq “On Item”}
$data = $assoc.AssociationData
$items = $list.Items
foreach($item in $items)
 {
 $wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
 }
$manager.Dispose()
$web.Dispose()

But be carefull:
1. be sure that you reffer to the specific workflow ( associated instance ).
2. powershell is running under proper user account to start the workflow manually.

This entry was posted in Powershell, Sharepoint, Workflow. Bookmark the permalink.