In this “start workflow in SharePoint” blog, we will learn how to start the SharePoint list workflow using PowerShell script. Many times, due to business reasons or technical problems we might need to start the SharePoint list workflow programmatically for all the list items.
Key Highlights: Start workflow in SharePoint using PowerShell
- How to start the SharePoint list workflow using PowerShell.
PowerShell script to start the SharePoint list workflow programmatically for all the list items.
Using the below PowerShell script we can start workflow in SharePoint:

#The below script is used to start the workflow in SharePoint list items programmatically. Add-PSSnapin Microsoft.Sharepoint.Powershell cls $fileName = "Workflow Start Report" #'yyyyMMddhhmm yyyyMMdd $enddate = (Get-Date).tostring("yyyyMMddhhmmss") #$filename = $enddate + '_VMReport.doc' $logFileName = $fileName +"_"+ $enddate+"_Log.txt" $invocation = (Get-Variable MyInvocation).Value $directoryPath = Split-Path $invocation.MyCommand.Path $directoryPathForLog=$directoryPath+"\"+"LogFiles" if(!(Test-Path -path $directoryPathForLog)) { New-Item -ItemType directory -Path $directoryPathForLog #Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } #$logPath = $directoryPath + "\" + $logFileName $logPath = $directoryPathForLog + "\" + $logFileName $isLogFileCreated = $False function Write-Log([string]$logMsg) { if(!$isLogFileCreated){ Write-Host "Creating Log File..." if(!(Test-Path -path $directoryPath)) { Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } else { $script:isLogFileCreated = $True Write-Host "Log File ($logFileName) Created..." [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } else { [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } $web = Get-SPWeb "http://server:port"; #Your site name $wfManager = $web.Site.WorkFlowManager; $myList = $web.Lists["TestList"]; #Your list name $association = $myList.WorkflowAssociations.GetAssociationByName("Test Workflow 2020","en-US"); #Pass your list name and culture string like en-US $myView = $myList.Views["All Items"]; #Pass the view name like "All Items" $listItems = $myList.GetItems($myView); $associationData = $association.AssociationData; foreach ($oneItem in $listItems) { try { $wf = $wfManager.StartWorkFlow($oneItem,$association,$associationData,$true); $message="Workflow has been started on: "+$oneItem Write-Host $message -BackgroundColor Green } catch { $ErrorMessage = $_.Exception.Message +"in starting the workflow on!: " +$oneItem Write-Host $ErrorMessage -BackgroundColor Red Write-Log $ErrorMessage } } Write-host "The execution has been completed Successfully "
Summary: Start workflow in SharePoint using PowerShell
Thus, in this PowerShell script – we have learned about how to start a SharePoint workflow for all items in the list using the PowerShell script programmatically or how to start a workflow on multiple items on a list.
- Learned about how to start the SharePoint list workflow using PowerShell.
See Also: SharePoint PowerShell tutorial
You may also like the following SharePoint PowerShell tutorials:
- How to fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error
- How to hide quick launch menu in SharePoint online using PnP PowerShell
- Edit user Permission is greyed Out SharePoint Online
- Get workflow inventory from SharePoint online using PowerShell CSOM
- Create a modern team site using PnP PowerShell in SharePoint
- In 2 steps convert a classic SharePoint page to modern using PnP
- SharePoint Online: Delete All Files from document library for the given date – PowerShell CSOM
- Create SharePoint online list using PnP provisioning template
- SharePoint Automation: PowerShell script to get remote server information
- Office 365: Retrieve hub sites and associated sites using PnP Powershell
- SharePoint Online Automation – O365 – Upload files to document library using PowerShell CSOM
- SharePoint Online Automation – O365 – Create multiple items in a list using PowerShell CSOM
- SharePoint Online Automation – O365 – Update document library metadata using PowerShell CSOM
- SharePoint Workflow Architecture – Part 1