This assessment and clean up process to get things ready for SharePoint online migration is pretty interesting. So there are some custom web services created for InfoPath forms so that it can get data and functions (lots of date functions) that is not available out of the box. So need to find all the published templates with the calls to these web services.
--updated with the code to include list templates not just document libraries.
So after thinking about what can be done with code and reviewing the InfoPath interop classes leading nowhere. I found an interesting article https://sharepintblog.com/2011/06/07/updating-infopath-form-templates-and-data-connections-with-powershell/
so with the code that they provided, i modified it to spit out all templates with the data connections to these web services.
Hope this helps since it is saving a lot of time and effort to track these down and find a workaround.
--updated with the code to include list templates not just document libraries.
Add-PSSnapin Microsoft.SharePoint.PowerShell
–erroraction SilentlyContinue
## the web
application to be searched for form libraries
$url =
'https://yoursharepointurl'
## temp
working directory
$dir =
'D:\ExtractedForms'
$findstring =
'findthis String'
$exportFile =
$false
foreach ($web
in (Get-SPWebApplication
$url |
Get-SPSite -Limit
All| Get-SPWeb -Limit All))
{
foreach($list
in $web.Lists)
{
if ($list.DocumentTemplateUrl -ne
$null -or
$list.ContentTypes[0].ResourceFolder.Properties["_ipfs_infopathenabled"])
{
if ($list.ContentTypes[0].ResourceFolder.Properties["_ipfs_infopathenabled"])
{
#--------------- get the templateurl for the list
template....
foreach($folder
in $list.RootFolder.SubFolders)
{
foreach($file
in $folder.Files)
{
if($file.Name -eq 'template.xsn')
{
$listUrl =
$web.Url
+ '/' + $list.RootFolder +
'/' + $folder.Name
$templateUrl =
$web.Url
+ '/' + $list.RootFolder +
'/' + $folder.Name
+'/template.xsn'
$exportFile =
$true
}
}
}
}
elseif ($list.DocumentTemplateUrl.ToString().ToLower().EndsWith(".xsn"))
{
$listUrl = $web.Url + '/' + $list.rootFolder
$templateUrl =
$web.Url
+ '/' + $list.DocumentTemplateUrl
$exportFile =
$true
}
if($exportFile)
{
## download the form template
$filename = $file.Name
$fileID = $file.UniqueId.Tostring()
$localfile =
$fileID +
"\" +
$filename
$file =
$web.GetFile($templateUrl)
$bytes = $file.OpenBinary();
# Download the file to the path
$localfile =
$dir +
"\" +
$localfile
New-Item "$dir\$fileID"
-type directory
-force | Out-Null
New-Item "$dir\$fileID\Extracted"
-type directory
-force | Out-Null
[System.IO.FileStream] $fs = New-Object System.IO.FileStream($localfile, "OpenOrCreate")
$fs.Write($bytes, 0 , $bytes.Length)
$fs.Close()
## crack open the form template
EXPAND "$localfile"
-F:* "$dir\$fileID\Extracted" |
Out-Null
## get file content and check for string
$extractedFiles =
Get-ChildItem "$dir\$fileID\Extracted"
*.x*
foreach ($extractedFile
in $extractedFiles)
{
$efn = $extractedFile.Name
$f = [System.IO.File]::Open("$dir\$fileID\Extracted\$efn" ,"open","read","Read")
$sr = New-Object System.IO.StreamReader
$f
$content = $sr.ReadToEnd()
$sr.close()
$f.close()
if ($content.Contains($findstring))
{
Write-Host $templateUrl
" : " $extractedFile.Name
-foreground green
}
}
}
$exportFile =
$false
}
}
$web.Dispose()
}