0

I am trying to figure out it what properties of $list or $wp return the status of workflow(Completed, In progress, Error Occurred and canceled). or how i can get the status of each workflow in the SP Farm. I managed to get Url, List name and etc. except workflow status.

$siteurl = Get-SPWebApplication https:// | Get-SPSite -Limit ALL

$siteurl="xxx"

function Get-Workflows($siteurl) {

$site=Get-SPSite -Limit ALL $WorkflowDeatils=@()

foreach($web in $site.AllWebs) { foreach($list in $web.Lists) { foreach($wf in $list.WorkflowAssociations) { if ($wf.Name -notlike "Previous Version") { $row=new-object PSObject add-Member -inputObject $row -memberType NoteProperty -name "Site URL" -Value $web.Url add-Member -inputObject $row -memberType NoteProperty -name "List Title" -Value $list.Title add-Member -inputObject $row -memberType NoteProperty -name "RootFolder" -Value $list.RootFolder add-Member -inputObject $row -memberType NoteProperty -name "Workflow name" -Value $wf.Name

Status of workflow ?

$WorkflowDeatils+=$row } } } } $WorkflowDeatils }

Get-Workflows | Export-csv C:\workflow.txt $site.Dispose();

0

To get workflow status, we can use the PowerShell script like below.

$siteURL = "http://sp2013/sites/team"
$site = Get-SPSite($siteURL)
foreach($web in $site.AllWebs){
    $wfm=New-objectMicrosoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
    foreach($spList in $web.Lists){     
        $workflowInstanceService=$wfm.GetWorkflowInstanceService()
        foreach($item in $spList.Items){
            $workflowInstances=$workflowInstanceService.EnumerateInstancesForListItem($spList.ID,$item.ID)
            foreach($wf in $workflowInstances) {
                write -host "workflow Status:" $wf.Status
            }                   
        }
    }
    $web.Dispose()
}

Refer to: SharePoint 2013 Workflow: Programmatically Access Workflow Properties

Or we can use the PowerShell with CSOM code to achieve it. Check the solution with source PowerShell script below.

How get the workflow execution status for all the workflows in a SharePoint Site

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.