Friday, June 9, 2017

Start Workflow using Powershell - SharePoint 2013


# URL of Site
$web = Get-SPWeb -Identity "https://weburl/url"

$manager = $web.Site.WorkFlowManager

# Name of the list
$list = $web.Lists["ListName"]

# Name of the Workflow
$assoc = $list.WorkflowAssociations.GetAssociationByName("WorkflowName","en-US")

$data = $assoc.AssociationData
$items = $list.Items
foreach($item in $items)
 {
 $wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
 }

$manager.Dispose()
$web.Dispose()
#

No comments:

Post a Comment