SharePoint Online-运行Powershell启动2010年工作流 [英] SharePoint Online - Running Powershell to Kick-Off 2010 Workflow

查看:74
本文介绍了SharePoint Online-运行Powershell启动2010年工作流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

我目前正在列表中同时运行2010和2013年的工作流程(一个用于获取广告信息,另一个作为对PowerShell的测试).我在网上找到了一个脚本,该脚本开始于2013年,但2010年却一无所获.有什么想法为什么找不到我的2010年工作流程?

I’m currently running both a 2010 and 2013 workflows on a list (one for grabbing AD info and the other as a test for PowerShell). I found a script online that starts my 2013, but I get nothing for the 2010. Any ideas why it’s not finding my 2010 workflow?

# Add Wave16 references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" 
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" 
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll"
 
# Specify tenant admin and site URL
$SiteUrl = "https://MYSITE.sharepoint.com/sites/IT-AssetManage/"
$ListName = "TESTING LIST NAME"
$UserName = "JSB@EMAIL.COM"
$SecurePassword = Read-Host -Prompt "Enter password" -AsSecureString
 
# Connect to site
$ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
$ClientContext.Credentials = $credentials
$ClientContext.ExecuteQuery()
 
Write-Host "About to Get List and List Items"

# Get List and List Items
$List = $ClientContext.Web.Lists.GetByTitle($ListName)
$ListItems = $List.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())
$ClientContext.Load($List)
$ClientContext.Load($ListItems)
$ClientContext.ExecuteQuery()
 
Write-Host "About to Retrieve WorkflowService related objects"

# Retrieve WorkflowService related objects
$WorkflowServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($ClientContext, $ClientContext.Web)
$WorkflowSubscriptionService = $WorkflowServicesManager.GetWorkflowSubscriptionService()
$WorkflowInstanceService = $WorkflowServicesManager.GetWorkflowInstanceService()
$WorkflowInstanceService = $WorkflowServicesManager.GetWorkflowInstanceService()

$ClientContext.Load($WorkflowServicesManager)
$ClientContext.Load($WorkflowSubscriptionService)
$ClientContext.Load($WorkflowInstanceService)
$ClientContext.ExecuteQuery()

Write-Host "About to Get WorkflowAssociations with List"

# Get WorkflowAssociations with List
$WorkflowAssociations = $WorkflowSubscriptionService.EnumerateSubscriptionsByList($List.Id)
$ClientContext.Load($WorkflowAssociations)
$ClientContext.ExecuteQuery()
 
Write-Host "About to Prepare Start Workflow Payload"

# Prepare Start Workflow Payload
$Dict = New-Object 'System.Collections.Generic.Dictionary[System.String,System.Object]'
 
  
Write-Host "About to Loop List Items to Start Workflow"


# Loop List Items to Start Workflow
For ($j=0; $j -lt $ListItems.Count; $j++){
    $msg = [string]::Format("Starting workflow {0}, on ListItemId {1}", $WorkflowAssociations[0].Name, $ListItems[$j].Id)
    Write-Host $msg
    #Start Workflow on List Item
    $Action = $WorkflowInstanceService.StartWorkflowOnListItem($WorkflowAssociations[0], $ListItems[$j].Id, $Dict)
    $ClientContext.ExecuteQuery()
} 

 

推荐答案

J.Smiley,

在SharePoint 2013内部部署中,我们需要配置Workflow Manager以启用SharePoint 2013工作流平台.据我所知,在Office 365 SharePoint Online中,工作流管理器 服务由Microsoft控制.

In SharePoint 2013 On-premise, we need to configure Workflow Manager to enable SharePoint 2013 workflow platform. And in Office 365 SharePoint Online, per my knowledge, Workflow Manager service is controlled by Microsoft.

要获得2013年的工作流程,我们需要通过WorkflowServicesManager实例连接到WorkflowInstanceService.对于2010年的工作流程,我们可以使用WorkflowAssociations对象,而无需 WorkflowServicesManager实例 .

To get the 2013 workflows, we need to connect to WorkflowInstanceService via WorkflowServicesManager instance. For the 2010 workflow, we can use WorkflowAssociations object without WorkflowServicesManager instance.

例如:

foreach(


listassociation在
listassociation in


list.WorkflowAssociations中) { 写主机
list.WorkflowAssociations) { Write-Host


这篇关于SharePoint Online-运行Powershell启动2010年工作流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆