Find all Lists and Libraries Where InfoPath is Used

Recently had the need to find and update most every InfoPath form in a production farm. This, mixed with the future demise of InfoPath, prompted the need to find or write a script. The below script will traverse every list and library in a given web app. The script can be easily modified to include every web app in a farm.

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
                Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$fileName = "C:\xsn-" + $(Get-Date -Format "yyyyMMddHHmmss") + ".csv"

$webApp = Get-SPWebApplication "http://webApp.sharepointed.com" 
"Title `t URL `t Type" | out-file $fileName

$(foreach($siteColl in $webApp.Sites)
{
                foreach($web in $siteColl.AllWebs)
                {
                foreach($list in $web.Lists) {                        
                
                                if ($list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -eq "XMLForm"){
                                                "$($list.title) `t $($list.parentweb.url)$($list.DefaultViewUrl) `t Library" | out-file $fileName -Append 
                                                                
                                                
                                }elseif ($list.ContentTypes[0].ResourceFolder.Properties["_ipfs_infopathenabled"]){
                                
                                                "$($list.title) `t $($list.ParentWeb.URL)$($list.DefaultViewUrl) `t List" | out-file $fileName -Append
                                                
                                                }
												else{
												$check = 0
								foreach($c in $list.ContentTypes) {
												if($c.DocumentTemplateUrl.ToString().EndsWith("xsn") -eq $true)
												{
													$check++			
												}
												}
												if($check -gt 0)
												{
													"$($list.title) `t $($list.ParentWeb.URL)$($list.DefaultViewUrl) `t List" | out-file $fileName -Append
												}
												}
												}}})

Inventory Web App Using PowerShell

Ask: We need an Excel spreadsheet that will list out all the Sites, List, Libraries for a given Web App in SharePoint.

Found this post link, then modified it for my needs.

function Get-WebAppInventory($WebAppName) {
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
    foreach ($spService in $farm.Services) {
        if (!($spService -is [Microsoft.SharePoint.Administration.SPWebService])) {
            continue;
        }

        foreach ($webApp in $spService.WebApplications) {
            if ($webApp -is [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]) { continue }
			if($webApp.name -eq $WebAppName)
			{
            foreach ($site in $webApp.Sites) {
                foreach ($web in $site.AllWebs) {
                        foreach ($list in $web.Lists) {
							$data = @{
								"Site" = $site.Url
                                "Web" = $web.Url
                                "list" = $list.Title
								"Type" = $list.BaseType	
								"Item Count" = $list.ItemCount
								"Last Item Modified" = $list.LastItemModifiedDate
							}
							
                            New-Object PSObject -Property $data
         
                    }
                }
            }
		}
        }
    }
}
#Get-WebAppInventory "SharePointed - name.sharepointed.com80" | Out-GridView
Get-WebAppInventory "SharePointed - name.sharepointed.com80" | Export-Csv -NoTypeInformation -Path c:\inventory2.csv

Above you have two options, Out-GridView or Export-CSV. You can use both or comment out one of the lines.

To get the parameter I’m passing to the function, you will need to look in Central Admin at your Web Apps list. Central Admin –> Application Management section –> Manage web applications. (_admin/WebApplicationList.aspx). In there, copy the name of the Web App.

You can modify the $data = @{ section to bring in other properties of the List.