Welcome to EMC Consulting Blogs Sign in | Join | Help

roberto.ortega

List all InfoPath forms for migration

Background

When performing any sort of migration with SharePoint, particularly if it is from an older to a newer version such as from MOSS 2007 to SharePoint 2010, it can be critical to identify the potential trouble spots. One area of concern is InfoPath forms. Often forms will break when ported to a new URL or to a newer version of SharePoint. It is important for any project that all the InfoPath document libraries be discovered from the outset. In this way, we can better estimate the migration effort, begin conversations with the end users for retirement of some forms, and have a testing plan for post-migration.

The Problem

At a client where we have a large MOSS 2007 site collection needs to be upgraded to SharePoint 2007, I needed a way to list all of the InfoPath forms and some additional helpful information about each so that I could efficiently get through over 300 sites. If done manually, it can be difficult to discern if a library is an InfoPath forms library. One manual way is to look at the icon used in All Site Content page or using the Content and structure tool. Even zooming in to 200% so that the icon is clearer, we may simply fail to spot one and we will certainly miss hidden lists. We also need to arm ourselves with certain usage information for any conversations with site owners. We need to know when the last use of the library was, how many current workflows may be running, etc. This information is very difficult and time consuming to gather manually.

The Solution

My solution was to create an administrative tool using PowerShell that would display the information that we needed. I did not find any free tools or code for this, so I simply created my own. It was fairly simple to output the following information for each InfoPath form that I found:

  • Web Title - The site the list was found on. This allowed me to group by this column and also
  • List Title
  • List Url - This is where the list is located. I was able to use this in an Excel report that created automatic estimates for our migration effort by taking into account the existence of InfoPath forms and other artifacts.
  • List Count - Some InfoPath document libraries had no documents and were either not ever used or not yet finalized.
  • List Modification Date - Some had not been used for many months. The owners didn't necessarily know the frequency of use or the last use.
  • List Workflow Count
  • List Live Workflow Count - We needed to discuss with end users what the cutover plan should be. In some cases the old form was kept for a period of time to allow users to finish their workflows.
  • List Live Workflows - This is the name of the workflows that were active. Some lists had multiple active workflows.
  • List Template - This helped locate the publishing location of the template that was at times in the document library itself or sometimes in a central location.

Here is the PowerShell code for the solution:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

function global:Get-SPSite($url){
    return new-Object Microsoft.SharePoint.SPSite($url)
}

#Change these variables to your site URL
$siteColletion = Get-SPSite(http://web.example.com/)
$webs = $siteColletion.allwebs
$websCount = $webs.count

"Site Name`tList Name`tUrl`tDocs`tLast Mod`tWF`tLive WF`tLive WF Names`tTemplate" > d:\temp\AllIPDocLibs.csv

#Walk through each site in the site collection
for($webIndex=0;$webIndex -ne $websCount;$webIndex++){
    $siteColletion = Get-SPSite(http://web.example.com/)
    $webs = $siteColletion.allwebs
    #use this for output
    $webTitle = $webs[$webIndex].title.toString()
    "PROCESSING $webTitle"
    
    #loop though each list in the current website
    for($i=0;$i -ne $webs[$webIndex].lists.count;$i++){

        $list = $webs[$webIndex].lists[$i]
        #this is used for output and to make the code a little more readable
        $listTitle = $list.toString()
        $listUrl = $list.DefaultViewUrl
        $listCount = $list.ItemCount

        if( $list.BaseType -eq "DocumentLibrary"  -and
         $list.BaseTemplate -eq "XMLForm"){
            $listModDate = $list.LastItemModifiedDate.ToShortDateString()
            $listTemplate = $list.ServerRelativeDocumentTemplateUrl
            $listWorkflowCount = $list.WorkflowAssociations.Count
            $listLiveWorkflowCount = 0
            $listLiveWorkflows = ""
            foreach ($wf in $list.WorkflowAssociations){
                if ($wf.Enabled){
                    $listLiveWorkflowCount++
                    if ($listLiveWorkflows.Length -gt 0){
                        $listLiveWorkflows = "$listLiveWorkflows, $($wf.Name)"
                    }
                    else {
                        $listLiveWorkflows = $wf.Name
                    }
                }
            }
           "$webTitle`t$listTitle`t$listUrl`t$listCount`t$listModDate`t$listWorkflowCount`t$listLiveWorkflowCount`t$listLiveWorkflows`t$listTemplate" >> d:\temp\AllIPDocLibs.csv
        }
    }
    $webs[$webIndex].Dispose()
    $siteColletion.Dispose()
    $webs = $null
    $siteCollection = $null
    [GC]::Collect()
}
#Dispose of the site object
$siteColletion.Dispose()
"Done"

Explanation

What's happening here? We start out generating a CSV file with the tab character as a separator. The outer loop iterates thru all of the sites in the site collection. For each site, we find each list and verify if it is an InfoPath form. To check this, we can test if the list is a document library and if its base template is XMLForm as follows:

$list.BaseType -eq "DocumentLibrary"  -and  $list.BaseTemplate -eq "XMLForm"

Subsequently, for each InfoPath forms library we gather the required information and output it to the CSV file

To run this I can use a command like the following:

PS >.\listAllIPDocLibs.ps1

Please be sure to provide a rating for this post. Thanks.

Published 25 October 2011 19:08 by roberto.ortega

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Personal Edition), by Telligent Systems