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
}
}
}}})