Start a workflow using PowerShell


Start a workflow on all / specific items in a list.

Change the site and workflow names to suit your requirements. I included a condition in this script to only start the workflow on items where ‘Status’ is not equal to Complete. You can remove this condition if you wish to run the script on all items in the list.


Use a PowerShell script to start the workflow.

#Site and List  
$SPAssignment = Start-SPAssignment 
$web = Get-SPWeb "http://your-site" -AssignmentCollection $spAssignment 
$site = Get-SPSite ""
$listToCancel = "your-list";
$web.AllowUnsafeUpdates = $true;
#Output file
$Today = Get-Date -Format "dd-M-yy"
$outFile = "c:\CancelWorkflowScript-Log-$Today.txt"
#Workflows to Remove
$wfToStart= "Name of workflow"
#List Name  
$list = $web.Lists[$listToCancel]; 
#Workflow Manager
$association=$list.WorkFlowAssociations | where {$_.Name -eq $wfToStart}
$association.AllowAsyncManualStart = $true
$association.AllowManual = $true
# Iterate through all Items in List and all Workflows on Items.  
	#Filtered List
	Write-Host "Restarting workflows.."
	foreach ($item in $list.Items) { 
		if ($item["Status"] -ne "Completed") {
			Write-Output "$wftoStart started on " $item.Name | Out-File $outFile -Append
		else {
			Write-Output $item.Name " - is completed " | Out-File $outFile -Append
Write-Host Finished.

Note: Workflows started using via PowerShell like this do not trigger other workflows when they complete, even if you have other workflows set to automatically start on item change.

Tags: ,

3 Responses to “Start a workflow using PowerShell”

  1. Sergey June 30, 2015 at 4:36 pm #

    Why use $site = Get-SPSite “”?

    • Erik November 6, 2015 at 5:10 pm #

      Because the WorkflowManager is a member of the site object, not web.


  2. Solomon March 14, 2017 at 8:52 pm #

    Hi ,

    you have mentioned in code “#Workflows to Remove
    $wfToStart= “Name of workflow”

    #List Name
    $list = $web.Lists[$listToCancel];”

    I believe it should be the code to restart the workflows for the list items which are having status other than completed ” Canceled,Terminated.etc etc)

    Please clarify

Leave a Reply

%d bloggers like this: