TransWikia.com

Getting SharePoint 2010 workflows running on SharePoint online list

SharePoint Asked on November 25, 2021

I am trying to get the SharePoint 2010 workflows running on the SharePoint list directly from the list name and not entering the list item.

But PnP PowerShell syntax needs me to enter the List item as well. Can you please help me with how can I modify the below script so that I don’t need to enter the list items and could directly get the result from the list name:

$SiteURL="Enter URL"
$List="Enter List Name"
$ListItem="I don't have to use this in my script"

Connect-PnPOnline -Url $SiteURL -Credentials (Get Credentials)
Get-PnPWorkflowInstance -List $List -ListItem $ListItem

Disconnect-PnPOnline

One Answer

You could use csom to get the SharePoint 2010 workflows, below is my sample:

$webUrl = "https://tenant.sharepoint.com/sites/michael"

$listName = "TestList"
$UserName="michael"
$Password ="password"
  
#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))


$context = New-Object Microsoft.SharePoint.Client.ClientContext $webUrl
$context.Credentials = $Credentials

$web = $context.Web
$list = $web.Lists.GetByTitle($listName)

$WorkflowAssociations =$list.WorkflowAssociations;
$context.load($WorkflowAssociations)
$context.ExecuteQuery()
$WorkflowAssociations

}

Answered by Michael Han_MSFT on November 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP