Jul 26 2022 09:29 AM - edited Jul 26 2022 09:30 AM
I have a powershell script to find the list for all suspended workflows in classic SP online site but i am getting error "Add-PsSnapin : No snap-ins have been registered for Windows PowerShell version 5".
On some research i found that this sript is for SP server
Can you please advise, how to modify it to use it with SP online. Thanks
if ( (Get-PSSnapin -Name "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.SharePoint.Powershell
}
$siteURL = "<Site URL>";
$libName = "<LibraryName>";
$spWeb = Get-SPWeb $siteURL;
$spList = $spWeb.Lists[$libName];
$spListItems = $spList.Items;
#Get the Workflow Manager object and then the instance of the Manager
$wfMgr = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($spWeb);
$wfInstanceSvc = $wfMgr.GetWorkflowInstanceService();
foreach($spListItem in $spListItems)
{
#Get a list of workflow instances running for the item in the library
$wfInstances = $wfInstanceSvc.EnumerateInstancesForListItem($spList.ID, $spListItem.ID);
foreach($wfInstance in $wfInstances)
{
#Check to see if the instance is suspended. If so, write it.
if($wfInstance.Status -eq "Suspended")
{
write-host("Instances for library item: {0}" -f $spListItem.ID);
}
}
}
Jul 27 2022 05:59 AM
Jul 27 2022 06:21 AM