Sharepoint 2013 工作流订阅服务不返回任何值

Sharepoint 2013 工作流订阅服务不返回任何值,sharepoint-2013,office365,powershell-3.0,sharepoint-workflow,Sharepoint 2013,Office365,Powershell 3.0,Sharepoint Workflow,我正在尝试通过powershell csom模型启动SharePoint 2013工作流。我已经浏览并获得了许多具有相同编码的链接。但就我而言,它不起作用。我在内部部署sharepoint 2013和sharepoint online中都尝试过,但都没有成功。代码如下: Set-ExecutionPolicy Unrestricted Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Exte

我正在尝试通过powershell csom模型启动SharePoint 2013工作流。我已经浏览并获得了许多具有相同编码的链接。但就我而言,它不起作用。我在内部部署sharepoint 2013和sharepoint online中都尝试过,但都没有成功。代码如下:

Set-ExecutionPolicy Unrestricted

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://spoffice365.sharepoint.com/"
$ListName = "Test"
$UserName = "myusername"
$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()

  # 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()

# Retrieve WorkflowService related objects
 $WorkflowServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($ClientContext, $ClientContext.Web)
$WorkflowSubscriptionService =  $WorkflowServicesManager.GetWorkflowSubscriptionService()
 $WorkflowInstanceService =   $WorkflowServicesManager.GetWorkflowInstanceService()
$ClientContext.Load($WorkflowServicesManager)
$ClientContext.Load($WorkflowSubscriptionService)
$ClientContext.Load($WorkflowInstanceService)
$ClientContext.ExecuteQuery()
# Get WorkflowAssociations with List
$WorkflowAssociations =    $WorkflowSubscriptionService.EnumerateSubscriptionsByList($List.Id)
 $ClientContext.Load($WorkflowAssociations)
$ClientContext.ExecuteQuery()

# Prepare Start Workflow Payload
$Dict = New-Object 'System.Collections.Generic.Dictionary[System.String,System.Object]'

 # 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()
 }  
下面的$WorkflowAssociations在sharepoint 2013和sharepoint online中均不返回任何值,始终为空,即使$List.Id正确传递并验证该列表已配置审批者工作流。

$WorkflowAssociations =    $WorkflowSubscriptionService.EnumerateSubscriptionsByList($List.Id)
 $ClientContext.Load($WorkflowAssociations)
$ClientContext.ExecuteQuery()
还想了解如何将审批人名称传递给以下方法:

 $WorkflowInstanceService.StartWorkflowOnListItem($WorkflowAssociations[0],  $ListItems[$j].Id, $Dict)