Run the Item level work-flow on Multiple Items based on a Status Column

$site = Get-SPWeb “http://xyz”
$web = Get-SPWeb “http://xyz/web”

$list = “ListName”;
$list = $web.Lists[$list];

$wfToStart= “WF_Name”

#Workflow Manager
$WorkflowManager=$site.WorkFlowManager
$association=$list.WorkFlowAssociations | where {$_.Name -eq $wfToStart}
$association.AllowAsyncManualStart = $true
$association.AllowManual = $true

foreach ($item in $list.Items) {
if ($item[“Status”] -eq “Complete”) {

$data=$association.AssociationData
$wf=$WorkflowManager.StartWorkFlow($item,$association,$data)
Write-Output “$wftoStart started on ” $item.Name

Write-Output $item.Name
}
}

$web.Dispose()
$site.Dispose()

Unknown's avatarAbout gkondameda
Gopi Kondameda is a Cloud Architect, SharePoint Saturday Speaker, developer and trainer with more than 18 years of experience in implementing solutions for clients ranging from small businesses to Fortune 500 companies, as well as governmental organizations. He has been involved in leading teams that implemented a wide range of Development projects, SharePoint Implementations and Migrations. He is passionate about leading teams, architecting solutions, designing information architectures as well as architecting various custom solutions, and integrating with line of business applications.

Leave a comment