Answered by:
How to Start a speific Workflow programatically in SharePoint 2010 via Powershell

Question
-
I was wanting to know how to start a specific Workflow named "Wofklow1" on a Document Library via Powershell for all documents in a document library as an example. How would I do this in Powershell? I think there is a SharePoint class that needs to be called but I cannot work it out.
Any help would be greatly appreciated.
Monday, May 14, 2012 2:01 AM
Answers
-
Hi,
Based on my knowledge, you can start a workflow using PowerShell:
$siteURL="http://servername:5555/"
$listName="Test"
$site=Get-Spsite $siteURL
$web=$site.RootWeb
$list=$web.Lists[$listName]
$item=$list.Items[0]
$manager=$site.WorkFlowManager
$association=$list.WorkFlowAssociations[0]
$data=$association.AssociationData
$wf=$manager.StartWorkFlow($item,$association,$data,$true)
For more information about starting workflow in PowerShell, check out the following articles:
http://www.moss2007.be/blogs/vandest/archive/2008/01/18/programmatically-start-workflow.aspx
Rock Wang
Rock Wang TechNet Community Support
- Edited by Rock Wang– MSFT Tuesday, May 15, 2012 7:46 AM
- Marked as answer by Rock Wang– MSFT Saturday, May 26, 2012 3:03 AM
Tuesday, May 15, 2012 7:45 AM
All replies
-
Hi,
Based on my knowledge, you can start a workflow using PowerShell:
$siteURL="http://servername:5555/"
$listName="Test"
$site=Get-Spsite $siteURL
$web=$site.RootWeb
$list=$web.Lists[$listName]
$item=$list.Items[0]
$manager=$site.WorkFlowManager
$association=$list.WorkFlowAssociations[0]
$data=$association.AssociationData
$wf=$manager.StartWorkFlow($item,$association,$data,$true)
For more information about starting workflow in PowerShell, check out the following articles:
http://www.moss2007.be/blogs/vandest/archive/2008/01/18/programmatically-start-workflow.aspx
Rock Wang
Rock Wang TechNet Community Support
- Edited by Rock Wang– MSFT Tuesday, May 15, 2012 7:46 AM
- Marked as answer by Rock Wang– MSFT Saturday, May 26, 2012 3:03 AM
Tuesday, May 15, 2012 7:45 AM -
Hello Rock Wang,
thank you for your response and my apologies for the response delay, that seemed to work a treat thank you.
Trent Nesic
Tuesday, May 29, 2012 11:59 AM -
Hi Trent,
You are welcome, I am gald to hear that.
Thanks,
Rock Wang
Rock Wang TechNet Community Support
Tuesday, May 29, 2012 12:24 PM -
HI Rock Wang,
i have similar problem
How we can delete workflow history list item which older then 3 or more month?
Why workflow history deleted associations but does not actually deleted the item form the list? So allowing that list to grow large any power shell command for this..
Deepesh Yevle - MCTS MCITP
- Edited by Deepesh Yevle Monday, March 18, 2013 11:58 AM added
Monday, March 18, 2013 11:57 AM