2
關於how to work with 2010 workflows using powershell有一些指南。有人能告訴我如何在2013年的工作流程中做同樣的事情嗎?他們不再列在$list.WorkFlowAssociations
之內。如何從PowerShell啓動工作流2013
關於how to work with 2010 workflows using powershell有一些指南。有人能告訴我如何在2013年的工作流程中做同樣的事情嗎?他們不再列在$list.WorkFlowAssociations
之內。如何從PowerShell啓動工作流2013
$siteURL = "URL"
$web = Get-SPWeb $siteURL
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$sub = $wfm.GetWorkflowSubscriptionService()
$subscriptions = $sub.EnumerateSubscriptionsByList($list.ID)
在$訂閱中,有相關的工作流程。希望它有幫助
這個MSDN blog post顯示了大部分答案,但他們試圖迭代列表而不是列表中的項目。以下是更新版本。
$sourceWebURL = '<URL>'
$sourceListName = '<List Name>'
$TargetWorkflow = '<Workflow Name>'
$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]
$items = $spSourceList.getItems()
#-- Getting a Workflow manager object to work with.
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($spSourceweb)
#-- Getting the subscriptions
$sub = $wfm.GetWorkflowSubscriptionService()
#-- Getting the specific workflow within the list of subscriptions on the specific list. (SP2010 associated workflows basically)
$WF = $sub.EnumerateSubscriptionsByList($spSourcelist.ID) | Where-Object {$_.Name -eq "$TargetWorkflow"}
#-- Getting a Workflow instance in order to perform my commands.
$wfis=$wfm.GetWorkflowInstanceService()
Foreach($item in $items){
#-- Creating the dictionary object I need to parse into StartWorkflow. This could be most other workflow commands.
$object = New-Object 'system.collections.generic.dictionary[string,object]'
$object.Add("WorkflowStart", "StartWorkflow");
$wfis.StartWorkflowOnListItem($WF, $item.ID, $object)
}
看到http://ranaictiu-technicalblog.blogspot.com/2013/05/programmatically-start-sharepoint-2013.html的詳細信息 – 2013-09-30 21:28:33