question

rameezhasan-1234 avatar image
0 Votes"
rameezhasan-1234 asked RaytheonXie-MSFT commented

PowerShell script to get Workflow Type and no. of actions

Hi,

I wanted to write a PowerShell Script which would run in a farm and get different types of workflow (SP designer, OOB wf) and also to get no. of actions if it is a Designer workflow to understand its complexity. Is it possible?

windows-server-powershellsharepoint-devsharepoint-workflow
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered RaytheonXie-MSFT commented

Hi @rameezhasan-1234 ,
We can only get status by following scripts. We are unable to get the number of actions

 Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
    
 $web = get-spweb -Identity https://spwebUrl
 $list = $web.Lists["ListName"]
    
 $wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
 $sub = $wfm.GetWorkflowSubscriptionService()
 $wfs = $sub.EnumerateSubscriptionsByList($list.ID)
 $wfis=$wfm.GetWorkflowInstanceService()
    
 foreach ($item in $list.Items)
 {
     $workflowInstances=$wfis.EnumerateInstancesForListItem($list.ID,$item.ID)
    
     foreach($wf in $workflowInstances) 
     {
         $wfName = $wfs | ?{$_.Id -eq $wf.WorkflowSubscriptionId} | select -ExpandProperty Name
         $wfID= $wf.ID
         $wfStatus = $wf.Status
         $wfListItem = $item.Name
    
         write-host "Workflow Title: $wfName Status: $wfStatus ListItem: $wfListItem"
     }
    
 }



If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @rameezhasan-1234 ,
Would you tell me whether your issue has been resolved or have any update?
I am looking forward to your reply.

Have a nice day!

Thanks,
Raytheon Xie

0 Votes 0 ·