Find all InfoPath forms in SharePoint using PowerShell

Find All InfoPath Forms in SharePoint using PowerShell

One comment

Loading

In this find all InfoPath forms in SharePoint article, we learn about how to find all InfoPath forms in SharePoint using the PowerShell script, which includes a list and template form. Before getting into the PowerShell script, let us understand what InfoPath Forms is and how it is integrated with SharePoint.

InfoPath Forms in SharePoint: Streamlining Data Collection and Workflow Automation

InfoPath Forms are a crucial tool in the SharePoint ecosystem, providing a user-friendly way to collect and manage data. InfoPath, part of Microsoft Office, allows users to design and deploy forms that integrate seamlessly with SharePoint. Despite Microsoft’s announcement to retire InfoPath, it remains widely used in many organizations. This article explores the functionality of InfoPath Forms in SharePoint, their benefits, how to create and deploy them, and considerations for the future.

What are InfoPath Forms?

InfoPath Forms are XML-based forms designed to collect and submit data. Originally launched by Microsoft in 2003, InfoPath allows users to create complex forms without extensive coding knowledge. These forms can be used for various purposes, including surveys, feedback forms, order forms, and more. When integrated with SharePoint, InfoPath Forms enable users to submit data directly to SharePoint lists and libraries, facilitating workflow automation and data management.

Benefits of Using InfoPath Forms in SharePoint

  1. User-Friendly Design:
    • InfoPath provides a drag-and-drop interface, making it easy for users to design forms without needing to write code.
  2. Seamless Integration with SharePoint:
    • Forms can be published directly to SharePoint lists and libraries, allowing for easy data collection and management.
  3. Customizable and Flexible:
    • InfoPath allows for extensive customization, including conditional formatting, data validation, and custom rules.
  4. Workflow Automation:
    • Combined with SharePoint workflows, InfoPath Forms can automate business processes, reducing manual effort and improving efficiency.
  5. Offline Capabilities:
    • InfoPath Forms can be filled out offline and submitted once the user is back online, making it useful for remote or mobile work scenarios.

Creating and Deploying InfoPath Forms in SharePoint

Step 1: Designing the Form in InfoPath Designer

  1. Open InfoPath Designer:
    • Launch InfoPath Designer from the Microsoft Office suite.
  2. Choose a Template:
    • Select a form template. Common templates include SharePoint List, SharePoint Form Library, and Blank Form.
  3. Design the Form:
    • Use the drag-and-drop interface to add controls such as text boxes, dropdowns, checkboxes, and more.
    • Configure data connections to fetch data from SharePoint or other data sources.
    • Apply rules and validation to ensure data integrity and guide user input.

Step 2: Publishing the Form to SharePoint

  1. Publish the Form:
    • Click on the File menu and select Publish.
    • Choose SharePoint Server and enter the URL of your SharePoint site.
  2. Configure Publishing Settings:
    • Specify whether the form will be published to a SharePoint list, form library, or as a site content type.
    • Define the form’s properties and data connections.
  3. Complete the Publishing Process:
    • Follow the prompts to complete the publishing process. The form will be deployed to the specified SharePoint location, ready for users to fill out.

Step 3: Using the Form in SharePoint

  1. Access the Form:
    • Navigate to the SharePoint list or library where the form was published.
    • Click on New to open the form and start entering data.
  2. Submit and Manage Data:
    • Users can submit the form, and the data will be stored in the SharePoint list or library.
    • Administrators can view, manage, and analyze the submitted data directly from SharePoint.

Considerations for the Future

While InfoPath has been a valuable tool for many organizations, Microsoft announced that it would retire InfoPath, with support ending in 2026. As a result, organizations should start planning for the transition to alternative solutions. Potential alternatives include:

  1. PowerApps:
    • Microsoft PowerApps is a robust platform for building custom forms and applications. It offers deep integration with SharePoint and other Microsoft 365 services.
  2. Microsoft Forms:
    • For simpler scenarios, Microsoft Forms provides an easy-to-use interface for creating forms and surveys, though it lacks the advanced capabilities of InfoPath.
  3. Third-Party Solutions:
    • Various third-party tools and services offer advanced form-building capabilities and can integrate with SharePoint.

Business Scenario: Find all InfoPath forms in SharePoint

Over the years, people from the various sector has been using the InfoPath form as it is a great tool, easy to develop any type of form in very less time, and it is part of the Microsoft Office product – I personally still like this product or tool very much. However, Microsoft does not recommend continuing with the InfoPath form as they are going to stop support after 2023 – at present this product is deprecated.

Considering this scenario, we need to plan for the migration of these InfoPath forms that you have in your ton-premise server. To be more concise, let’s say you have lots of InfoPath forms in the SharePoint on-premise environment, now you are planning to migrate your on-premise sites to SharePoint Online, then definitely we need to re-develop the InfoPath form using modern technologies like Power Apps, Nintex Forms, Nintex Cloud form tool.

So, before starting the migration we must have a detail of all InfoPath forms inventory like these forms hosted in which list/library so that we could analyze the InfoPath forms beforehand before we start developing these forms using other modern technologies or tools.

Find all InfoPath forms in SharePoint and export them into a CSV file using PowerShell script

Using the below PowerShell script we can find all InfoPath forms and export them into a CSV file.


#The below script is used to get the all infopath form details from the SharePoint 2016 on-premise environment using the PowerShell script.
cls

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

$fileName = "InfopathFormInventoryReport"
#'yyyyMMddhhmm yyyyMMdd
$enddate = (Get-Date).tostring("yyyyMMddhhmmss")
#$filename = $enddate + '_VMReport.doc'
$logFileName = $fileName +"_"+ $enddate+"_Log.txt"
$invocation = (Get-Variable MyInvocation).Value
$directoryPath = Split-Path $invocation.MyCommand.Path

$directoryPathForLog=$directoryPath+"\"+"LogFiles"
if(!(Test-Path -path $directoryPathForLog))
{
New-Item -ItemType directory -Path $directoryPathForLog
#Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
#$logPath = $directoryPath + "\" + $logFileName

$logPath = $directoryPathForLog + "\" + $logFileName

$isLogFileCreated = $False

function Write-Log([string]$logMsg)
{
if(!$isLogFileCreated){
Write-Host "Creating Log File..."
if(!(Test-Path -path $directoryPath))
{
Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
else
{
$script:isLogFileCreated = $True
Write-Host "Log File ($logFileName) Created..."
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
else
{
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}

#######The below function will get the details from SharePoint on-premise web application whether they contain infopath form or not.############################

function GetInfopathFormDetailsFromSharePointOnPremise()
{
param
(
[Parameter(Mandatory=$true)] [string] $WebAppURL

)

$targetReportPath="C:\InfoPathFormsInventory.csv"
#This is an array to store ResultItem - PSObjects
$ResultCollArray = @()

#Get all webs of the given web application
$WebsCollection = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Get-SPWeb -Limit All

$formCount=0;
#Looping thru the collection of webs from the web collection.
foreach($oneSPWeb in $WebsCollection)
{

#Get all lists/libraries with InfoPath List Forms in use condition.
foreach ($oneList in $oneSPWeb.Lists)
{
$ResultItem = new-object PSObject

if($oneList.ContentTypes[0].ResourceFolder.Properties["_ipfs_infopathenabled"] -eq $true)
{
$formCount=$formCount+1;
$listModDate = $oneList.LastItemModifiedDate.ToShortDateString()

Write-Host "The code has found an InfoPath form at: $($oneSPWeb.URL), $($oneList.oneList)"
#$ResultItem = new-object PSObject

try
{

$ResultItem | add-member -membertype NoteProperty -name "Site URL" -Value $oneSPWeb.Url
$ResultItem | add-member -membertype NoteProperty -name "List Name" -Value $oneList.Title
$ResultItem | add-member -membertype NoteProperty -name "List URL" -Value "$($oneSPWeb.Url)/$($oneList.RootFolder.Url)"
$ResultItem | add-member -membertype NoteProperty -name "Template" -Value $oneList.ContentTypes[0].ResourceFolder.Properties["_ipfs_solutionName"]
$ResultItem | add-member -membertype NoteProperty -name "ListLastModifiedDate" -Value $listModDate

$ResultCollArray += $ResultItem

}
catch
{
$ErrorMessage = $_.Exception.Message +"in the GetInfopathFormDetailsFromSharePointOnPremise script!: "
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage

}
}
if( $oneList.BaseType -eq "DocumentLibrary" -and $oneList.BaseTemplate -eq "XMLForm")
{
$formCount=$formCount+1;
#$ResultItem = new-object PSObject
try
{

$listModDate = $oneList.LastItemModifiedDate.ToShortDateString()
Write-Host "The code has found an InfoPath form at: $($oneSPWeb.URL), $($oneList.oneList)"
$ResultItem | add-member -membertype NoteProperty -name "Site URL" -Value $oneSPWeb.Url
$ResultItem | add-member -membertype NoteProperty -name "List Name" -Value $oneList.Title
$ResultItem | add-member -membertype NoteProperty -name "List URL" -Value "$($oneSPWeb.Url)/$($oneList.RootFolder.Url)"
$ResultItem | add-member -membertype NoteProperty -name "Template" -Value $oneList.ServerRelativeDocumentTemplateUrl
$ResultItem | add-member -membertype NoteProperty -name "ListLastModifiedDate" -Value $listModDate
$ResultCollArray += $ResultItem

}
catch
{
$ErrorMessage = $_.Exception.Message +"in the GetInfopathFormDetailsFromSharePointOnPremise script!: "
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage

}

}
Write-Host "Form Count: " $formCount
}

#Export the results to a CSV File in the given location.
#$ResultCollArray | Export-csv $targetReportPath -notypeinformation
#Write-Host "The InfoPath Forms Report has been generated successfully!" -f Green

}

#Export the results to a CSV File in the given location.
$ResultCollArray | Export-csv $targetReportPath -notypeinformation
Write-Host "The InfoPath Forms Report has been generated successfully!" -f Green

}

####################Testing - calling the function########################################################

try
{

GetInfopathFormDetailsFromSharePointOnPremise "http://server:port" #Your WebAppURL

$message="The GetInfopathFormDetailsFromSharePointOnPremise function execution has been completed successfully."
Write-Host $message -BackgroundColor Green

}
catch
{
$ErrorMessage = $_.Exception.Message +"in the GetInfopathFormDetailsFromSharePointOnPremise script!: "
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage
}
####################Testing - calling the function ends here####################################

Note:

From the above code the below two lines are key to check the InfoPath Form condtion:

  • if($oneList.ContentTypes[0].ResourceFolder.Properties[“_ipfs_infopathenabled”] -eq $true)
  • if( $oneList.BaseType -eq “DocumentLibrary” -and $oneList.BaseTemplate -eq “XMLForm”)

First, if the condition checks whether the “_ipfs_infopathenabled” list property is set to true and the second condition checks that the list base type is “Document Library” and the base template is “XMLForm”.

Summary: Find all InfoPath forms in SharePoint

Thus, in this article, we have learned about how to find all InfoPath forms from SharePoint on-premise using the PowerShell script.

InfoPath Forms have played a significant role in streamlining data collection and workflow automation in SharePoint environments. Despite its pending retirement, InfoPath remains a powerful tool for creating and managing forms. By understanding its capabilities and preparing for future transitions, organizations can continue to leverage InfoPath effectively while exploring new solutions to meet their evolving needs.

See Also: SharePoint PowerShell Tutorials

You may also like the following SharePoint PowerShell tutorials:

Download SharePoint Online PDF Book

Download SharePoint Online & Office 365 Administration eBook

Buy the premium version of SharePoint Online & Office 365 administration eBook from here:



Buy SharePoint Online & Office 365 Administration eBook


 

Get the free demo PDF eBook from here:

FREE DOWNLOAD

Send download link to:

Subscribe to get exclusive content and recommendations every month. You can unsubscribe anytime.

 

About Post Author

1 comments on “Find All InfoPath Forms in SharePoint using PowerShell”

Do you have a better solution or question on this topic? Please leave a comment