PowerShell script to get Workflow Type and no. of actions

rameez hasan 6 Reputation points
2022-03-30T10:44:17.887+00:00

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?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,938 questions
SharePoint Workflow
SharePoint Workflow
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Workflow: An orchestrated and repeatable pattern of business activity, enabling data transformation, service provision, and information retrieval.
571 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,510 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 34,986 Reputation points Microsoft Vendor
    2022-03-31T07:07:46.997+00:00

    Hi @rameez hasan ,
    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.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.