kwizcom banner advertisement

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.
Find All InfoPath Form Libraries in SharePoint Web Application

Find All InfoPath Form Libraries in SharePoint Find All InfoPath Form Libraries in SharePoint Reviewed by Salaudeen Rajack on 2:24 PM Rating: 5


  1. Nice script! Thanks for sharing.

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

  3. looks like in MOSS 2007 you need to add one more function Get-SPWebApplication.

    Then $SiteColletion = Get-SPSite($MyWebURL)
    #Get All Web Applications
    Function global:Get-SPWebApplication($WebAppURL)
    if($WebAppURL -eq $null) #Get All Web Applications
    #Sharepoint 2007 powershell spfarm
    $Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
    $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
    $WebApps = @()
    foreach ($websvc in $websvcs) {
    foreach ($WebApp in $websvc.WebApplications) {
    $WebApps+ = $WebApp
    return $WebApps
    else #Get Web Application for given URL
    return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)

  4. Does this work for O365 as well?


Please Login and comment to get your questions answered!

Powered by Blogger.