Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am migrating a sharepoint farm and need to update all SPD workflows in the migrated site collection. I need to get a list of all SPD workflows that exist in the site collection so I can update URLs, email addresses etc.

I know I can open each site in SPD and check for workflows from there - however, there are over a 100 sites and subsites and I'm sure there is a better way to list all workflows (SQL query, Powershell script).

Any help would be appreciated, Greg

Update: Ok, so a quick and dirty way of listing all workflows is to run the following SQL query on the content DB

SELECT dirname, leafname FROM allDocs WHERE LeafName LIKE '%.xoml'

If anyone has a better way (Powershell anyone?) let me know.

share|improve this question
    
When I try to run this script on my MOSS SP 2007 Service Pack 3, Win Server 2003 system, with PowerShell v1, I get the error New-Object : A parameter cannot be found that matches parameter name 'Property'. At C:\Documents and Settings\sa_sps\My Documents\WindowsPowerShell\listworkflow.ps1:24 char:59 + New-Object PSObject -Property <<<< $hash | Sort-Object Does anyone know of a fix for this in the powershell v1 environment? –  LVirden Jul 3 '13 at 16:34
add comment

2 Answers

You can do this using Powershell. Loop through all sites in your site collection, then all lists, then all workflow associations.

$site = Get-SPSite("your-site-url");
$site.AllWebs | foreach { $_.Lists | foreach { $_.WorkflowAssociations | foreach { 
  write-host "Site:" $_.ParentWeb.Url ", List:" $_.ParentList.Title ", Workflow:" $_.Name
} } }
share|improve this answer
    
Perfect, thanks!! –  Greg Farlan Jul 5 '11 at 7:52
    
You're welcome. If this solves your problem, make sure you check it as your selected answer. That will help folks later. –  Laurie Jul 5 '11 at 14:16
    
Or failing that, maybe somebody will come along and at least give it an upvote... +1 –  SPDoctor Aug 2 '11 at 12:12
    
All who replied... Say, the poster said he was "migrating", strongly implying that what he needs to examine is a SharePoint 2007 farm. That said, is the Powershell script offered valid? That is, out-of-the-box SharePoint 2007 DOES have Powershell, but NOT "SharePoint-SAVVY" Powershell, so is the cmdlet suggested - "Get-SPSite" even VALID without somehow enhancing his SharePoint 2007 install with a .ps1 file which teaches it how to perform a Get-SPSite cmdlet? I'm facing the same challenge with a client's SP2007 farm, and don't see how the OOTB PowerShell available in my SP2007 farm is going to –  user7390 Mar 16 '12 at 2:12
add comment

Check this code, i dont remember but find it somewhere in the WEB: It listing all workflows inside one site collection and generating CSV table.

#Load SharePoint 2007 Assemblies
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null

$siteurl="http://site.domain.com"
$site=new-object Microsoft.SharePoint.SPSite($siteurl)

#Initialize Workflow Count variable
$workflowcount = 0

#Foreach loop to loop through all webs, and lists with workflow associations, and exclude workflows that have previous versions and write findings to .csv file.

function Get-Workflows()
{
    foreach($web in $site.AllWebs)
    {
            foreach($list in $web.Lists)
            {
                foreach($wf in $list.WorkflowAssociations)
                {
                        if ($wf.Name -notlike "*Previous Version*")
                        {
                            $hash = @{"[URL]"=$web.Url;"[List Name]"=$list.Title;"[Workflow]"=$wf.Name}
                             New-Object PSObject -Property $hash | Sort-Object

                        }
                }
            }
    }
}

foreach($web in $site.AllWebs)
{
    foreach($list in $web.Lists)
    {
        foreach($wf in $list.WorkflowAssociations)
        {
            if ($wf.Name -notlike "*Previous Version*")
            {
               $workflowcount += 1
            }
        }
    }
}

Get-Workflows | Export-csv E:\workflows.csv
"Workflow Count " + $workflowcount >> E:\workflows.csv

$site.Dispose()
share|improve this answer
    
How is this code differentiate the list of workflows returned by this code are workflow build out of the box workflows or SPD build workflows? –  user25169 Apr 15 at 23:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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