Monday, January 28, 2013

How to Start a SharePoint Workflow using PowerShell

Requirement is: To start a specific Workflow on All documents in a document library.

Solution: Lets use PowerShell to Start workflow Programmatically on all Items in a Document Library! After making sure, Manual start is enabled for the workflow:

# For MOSS 2007 compatibility

#Region MOSS2007-CmdLets
Function global:Get-SPSite()
  Param( [Parameter(Mandatory=$true)] [string]$SiteCollURL )

   if($SiteCollURL -ne '')
    return new-Object Microsoft.SharePoint.SPSite($SiteCollURL)
Function global:Get-SPWeb()
 Param( [Parameter(Mandatory=$true)] [string]$SiteURL )
  $site = Get-SPSite($SiteURL)
        if($site -ne $null)
    return $web

#Get the Web
$web = Get-SPWeb ""

#Get the List
$list=$web.Lists["Review Documents"]

#Get Workflow Manager

#Get the specifi workflow, Associated with the list
$WFAssociation = $list.WorkFlowAssociations | where {$_.Name -eq "Approval Workflow"}

#Start Workflow on Each List Item
foreach ($item in $list.Items)
    write-host "Started Workflow on $($item.Name)"
Using this method, We can Start/Stop/Cancel even Nintex Workflows!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. Exception calling "StartWofkflow" with "3" argument(s): "Unable to synchronously deliver start event via a manual start workflow.: $$WFManager.StartWorkflow($item......

    1. Try adding the user who runs this code with "FULL Control" access rights to the site!

  2. Does this work on SharePoint 2013


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...