Home > PowerShell, SharePoint Administration > Getting a list of all Workflow Associations from a SharePoint 2007 Site Collection using PowerShell

Getting a list of all Workflow Associations from a SharePoint 2007 Site Collection using PowerShell

Migrating from SharePoint 2007 to SharePoint 2010 takes a lot of preparation and coordination to have a successful migration.  This means taking into consideration all customizations, permissions, and workflows.  To prepare for a migration between SharePoint 2007 and SharePoint 2010 I wanted to get a list of all workflows (SPD & Nintex) on a specific Site Collection before migration.
Below is the script I used in SharePoint 2007 to do this, and spits out a .csv file.  Later I will update this blog posting to show you how to do it in SharePoint 2010

——————————————————————————————————————————————————–

***UPDATED SCRIPT TO US A FUNCTION TO GENERATE A HASH TABLE TO EXPORT TO A .CSV FILE, FOR BETTER FORMATTING**********************

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

$siteurl=”http://portal/site”
$site=new-object Microsoft.SharePoint.Site($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 -nolike “*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 -nolike “*Previous Version*”)
            {
               $workflowcount += 1
            }
        }
    }
}

Get-Workflows | Export-csv c:\temp\workflows.csv
“Workflow Count ” + $workflowcount >> c:\temp\workflows.csv

$site.Dispose()

——————————————————————————————————————————————————

Advertisements
  1. m
    August 5, 2013 at 4:24 am

    can you let me know how to modify this code for SharePoint 2007 site

    • August 5, 2013 at 3:55 pm

      This is for SP2007, are you meaning SP2010?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: