Thursday, September 27, 2012

Find All InfoPath Form Libraries in SharePoint

During a Corporate Re-branding project, implemented new logo, color themes all over the SharePoint sites and now, the new Logo must be changed in All the InfoPath Form Libraries!

It was really challenging to manually find InfoPath form libraries in a Large environment with 1500+ site collections. Automation? PowerShell!

Luckily, this time found a partial PowerShell script written by EMC SharePoint consultants and modified the script to get all the InfoPath Form libraries of the web application.

Here goes the PowerShell script to find all InfoPath Form Libraries of the All Site collections.

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

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

#Get the web application
Write-Host "Enter the Web Application URL:"
$WebAppURL= Read-Host
$SiteColletion = Get-SPSite($WebAppURL)
$WebApp = $SiteColletion.WebApplication

#Write the CSV header
"Site Collection `t Site `t List Name `t List Url `t Docs Count `t Last Modified `t WF Count `t Live WF `t Live WF Names `t Form Template" > c:\InfoPathLibs.csv

#Loop through all site collections of the web app
    foreach ($site in $WebApp.Sites)
       # get the collection of webs
       foreach($web in $site.AllWebs)
            write-host "Scaning Site" $web.title "@" $web.URL
               foreach($list in $web.lists)
                   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)
                        if ($listLiveWorkflows.Length -gt 0)
                            $listLiveWorkflows = "$listLiveWorkflows, $($wf.Name)"
                            $listLiveWorkflows = $wf.Name
       #Write data to CSV File
                   $site.RootWeb.Title +"`t" + $web.Title +"`t" + $list.title +"`t" + $Web.Url + "/" + $List.RootFolder.Url  +"`t" + $list.ItemCount +"`t" + $listModDate +"`t" + $listWorkflowCount +"`t" + $listLiveWorkflowCount +"`t" + $listLiveWorkflows +"`t" + $listTemplate >> c:\InfoPathLibs.csv

#Dispose of the site object
Write-host  "Report Generated at c:\InfoPathLibs.csv" -foregroundcolor green 

Report Screenshot:
Here  is the output of the report which has all the InfoPath Form libraries of the provided web application.
Report shows All InfoPath Form Libraries in the web application

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. Nice script! Thanks for sharing.

  2. perfect thanks!!...
    is there we can also check whether form contains UserProfileConnection


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...