0

We migrated an InfoPath form from SharePoint on prem to SharePoint Online. For example from site http://teamsites.MyCompany.local/SiteA to http://MyCompany.sharepoint.com/sites/siteA. In SharePoint Online we have alot of InfoPath xml files with a reference url to the old on prem SharePoint site. What is the best practice to search or these InfoPath xml files? I try to use the search functionality but it is not possible to search inside the content of an xml file.

In the InfoPath xml files you will see something like this:

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.1940" productVersion="15.0.0" PIVersion="1.0.0.0" href="http://teamsites.MyCompany.local/SiteA/SomeDocumentLibrary/Forms/template.xsn" name="urn:schemas-microsoft-com:office:infopath:Contractgenerator2-0:-myXSD-2012-02-24T10-34-32" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?><?mso-infoPath-file-attachment-present?><my:mijnVelden xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-02-24T10:34:32" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="nl">

1 Answer 1

0

We can execute the below PnP PowerShell:

$rootUrl = "https://yourDomain.sharepoint.com"   # enter your URL
Connect-PnPonline $rootUrl 

Get-PnPTenantSite | 
foreach { 
Write-Host "Checking " $_.Url; # status message, delete if not needed.
Connect-PnPonline $_.url

    $web = Get-PnPWeb

    $parentTitle = $web.Title
    $parentUrl = $web.Url

    $listsIncForm = Get-PnPList 



    forEach ( $list in $listsIncForm) {
        $listTitle = $list.Title
        $listType = $list.BaseTemplate
        $listUrl = $list.DefaultViewUrl



        if ( $listType -eq 100 -or $listType -eq 101 ) {
            $currList = Get-PnPList $listTitle -Includes ContentTypes, Forms, IsSystemList

            $listForms = $currList.Forms
            $isSysList = $currList.IsSystemList

            if ( $isSysList ) {
                #Write-Host 'Sys List Ignore'
            } else {
                if ( $listType -eq 101 ) {
                    $contentTAllow = $currList.AllowContentTypes
                    if ( $contentTAllow ) {
                        $contentTyps = $currList.ContentTypes
                        forEach ($contType in $contentTyps) {
                            if ( $contType.Name -eq 'Form' ) {
                                Write-Host "InfoPath Found in Library" $listTitle " at URL " $listUrl -ForegroundColor Green
                            }
                        }
                    }

                }
                else {
                    forEach ( $listFm in $listForms ) {
                        $listPath = $listFm.ServerRelativeUrl
                        if ( $listPath -like '*displayifs.aspx' ) {
                            Write-Host 'InfoPath Found in List ' $listTitle " at URL " $listUrl -ForegroundColor Green

                        }
                    }
                }
            }

        }
    }

Get-PnPSubWebs -Recurse |
  where { $_.url -like $rootUrl+"*" } |   # skip app sites and OneDrives
  foreach { 
    Write-Host "Checking " $_.Url; # status message, delete if not needed.

    Connect-PnPOnline -Url $_.Url

    $web = Get-PnPWeb

    $parentTitle = $web.Title
    $parentUrl = $web.Url

    $listsIncForm = Get-PnPList 



    forEach ( $list in $listsIncForm) {
        $listTitle = $list.Title
        $listType = $list.BaseTemplate
        $listUrl = $list.DefaultViewUrl



        if ( $listType -eq 100 -or $listType -eq 101 ) {
            $currList = Get-PnPList $listTitle -Includes ContentTypes, Forms, IsSystemList

            $listForms = $currList.Forms
            $isSysList = $currList.IsSystemList

            if ( $isSysList ) {
                #Write-Host 'Sys List Ignore'
            } else {
                if ( $listType -eq 101 ) {
                    $contentTAllow = $currList.AllowContentTypes
                    if ( $contentTAllow ) {
                        $contentTyps = $currList.ContentTypes
                        forEach ($contType in $contentTyps) {
                            if ( $contType.Name -eq 'Form' ) {
                                Write-Host "InfoPath Found in Library" $listTitle " at URL " $listUrl -ForegroundColor Green
                            }
                        }
                    }
                }
                else {
                    forEach ( $listFm in $listForms ) {
                        $listPath = $listFm.ServerRelativeUrl
                        if ( $listPath -like '*displayifs.aspx' ) {
                            Write-Host 'InfoPath Found in List ' $listTitle " at URL " $listUrl -ForegroundColor Green

                        }
                    }
                }
            }
        }
      }
   }
 }

Source:

Get the list of all available InfoPath forms in a SharePoint Site Collection - SharePoint Online

OR

We can execute the below PowerShell script in your source SharePoint on-premise environment to get all InfoPath form details:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Configuration parameters
$WebAppURL="https://intranet.crescent.com"
$ReportOutput="C:\InfoPath-ListForms.csv"
#Array to Hold Result - PSObjects
$ResultColl = @()
 
#Get All Webs of the Web Application
$WebsColl = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Get-SPWeb -Limit All
 
#Iterate through each web
Foreach($Web in $WebsColl)
{
 #Get All Lists with InfoPath List Forms in use
 Foreach ($List in $web.Lists | Where { $_.ContentTypes[0].ResourceFolder.Properties["_ipfs_infopathenabled"]})
    {
            Write-Host "Found an InfoPath Form at: $($Web.URL), $($List.Title)"
            $Result = new-object PSObject
            $Result | add-member -membertype NoteProperty -name "Site URL" -Value $web.Url
            $Result | add-member -membertype NoteProperty -name "List Name" -Value $List.Title
            $Result | add-member -membertype NoteProperty -name "List URL" -Value "$($Web.Url)/$($List.RootFolder.Url)"
            $Result | add-member -membertype NoteProperty -name "Template" -Value $list.ContentTypes[0].ResourceFolder.Properties["_ipfs_solutionName"]
            $ResultColl += $Result
    }
}
#Export Results to a CSV File
$ResultColl | Export-csv $ReportOutput -notypeinformation
Write-Host "InfoPath Lists Forms Report has been Generated!" -f Green

Note:

  • After exporting the report - you can replace your on-premise site URL with SharePoint online site URL - so that we can identify that these lists contain InfoPath form template.

Source:

Find All InfoPath List Forms in SharePoint using PowerShell

4
  • Hi, thank you or the example. Our organisation are saving the infopath forms manual in some normal document library. These document libraries are not form libraries with some form as contenttype. So I need some logic to search in files and check if there is some text of the infopath form. For example the text "/Forms/template.xsn".
    – Jackson
    Jun 19, 2020 at 14:16
  • OK, then you can loop through all items from the document library and inside the loop check the file extension. XSN..... If file type. XSN then export those into a csv file.... you can refer this example :sharepointdiary.com/2018/08/…
    – SP 2022
    Jun 19, 2020 at 14:27
  • This is more relevant to get the specific file type from SharePoint online document library :global-sharepoint.com/powershell/…
    – SP 2022
    Jun 19, 2020 at 14:46
  • hi, they are not xsn files. They are xml files. Xsn is the form and xml is an instance of the form which you can save somewhere. So I cannot search on type. I need to search for the infopath xml files.
    – Jackson
    Jun 19, 2020 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.