Find All InfoPath Form Libraries in SharePoint using PowerShell

During a Corporate Re-branding project, implemented a 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! Here goes the PowerShell script to find all InfoPath Form Libraries of All Site collections.

PowerShell to Find All InfoPath Form Libraries in SharePoint:

[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 = [string]::Empty;
                   Foreach ($wf in $list.WorkflowAssociations)
                           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

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

4 thoughts on “Find All InfoPath Form Libraries in SharePoint using PowerShell

  • November 9, 2017 at 8:15 PM

    Does this work for O365 as well?

  • January 25, 2017 at 3:38 AM

    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)

  • February 10, 2016 at 10:00 AM

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

  • December 4, 2015 at 6:22 PM

    Nice script! Thanks for sharing.


Leave a Reply