I'm new to the Workflow Object Model in MOSS 2007, and trying to find an example of C# code that does the same as this SP2010 PowerShell?

//get all the lists
$lists = $web.Lists
foreach ($list in $lists)
    //loop through and print out the workflow name and number of running instances
    foreach ($listassociation in $list.WorkflowAssociations)
        $associations += $($listassocation.name)
        if($associations.count -ge 1)
            Write-Host "Description:" $listassociation.Description
            Write-Host "Running Instances: " $listassocation.RunningInstances


1 Answer 1


In terms of iterating through all sites, in your site collection, and outputting the workflows associated, you can do the following powershell script.

$site = Get-SPSite("your-site-url");
$site.AllWebs | foreach { $_.Lists | foreach { $_.WorkflowAssociations | foreach { 
  write-host "Site:" $_.ParentWeb.Url ", List:" $_.ParentList.Title ", Workflow:" $_.Name
} } }

You can slightly modify to extrapolate your needed additional properties.

  • Quinn, thanks for the code, but unfortunately, this only worked for me in SP2010. For MOSS 2007 workflow details, I ended up using the .NET code above from within a PowerShell script. May 7, 2015 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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