Forum Discussion
Audi86
Jul 26, 2022Brass Contributor
PowerShell to find all suspended workflow for classic SharePoint online sites
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);
}
}
}
2 Replies
- SchnittlauchIron ContributorHi,
looks like this error here
https://social.technet.microsoft.com/Forums/azure/en-US/664ca8b5-551e-4956-8912-c718e1661a79/powershell-addpssnapin-produces-quotno-snapins-have-been-registered-for-windows-powershell
Best regards,
Schnittlauch
"First, No system is safe. Second, Aim for the impossible. Third, no Backup, no Mercy" - Schnittlauch
My answer helped you? Don't forget to leave a like. Also mark the answer as solved when your problem is solved. 🙂- Audi86Brass Contributorhi Schnittlauch,
yes that thread i already seen and mentioned that in my question that this script may be for server side. Do you know how can I modify it to use with SharePoint online?
Thanks