Find All InfoPath Form Libraries in SharePoint Online using PowerShell
Requirement: Find All InfoPath Form libraries in SharePoint Online.
How to Find All InfoPath Form Libraries in SharePoint Online Site?
In SharePoint Online, InfoPath forms can be stored in form libraries, which are special types of document libraries that are designed to store and manage InfoPath forms. If you need to find all the InfoPath form libraries in your SharePoint Online environment, you can use PowerShell. In this tutorial, we will discuss how to find all the InfoPath form libraries in SharePoint Online using PowerShell.
To get all form libraries in the SharePoint Online site collection, use the below PowerShell script. This script checks if the template ID of any list is 115 to decide whether it’s an XML Forms Library (SharePoint Online List Template IDs Reference).Â
#Function to Get Form Libraries
Function Get-PnPFormLibraries
{
[cmdletbinding()]
param(
[parameter(Mandatory = $true, ValueFromPipeline = $True)]$Web,
[parameter(Mandatory = $true, ValueFromPipeline = $False)][String] $CSVPath
)
Try {
Write-host "Searching Web '$($Web.URL)'" -f Yellow
#Get All Form libraries
$Lists= Get-PnPProperty -ClientObject $Web -Property Lists
$FormLibraries = $Lists | Where-Object {$_.BaseTemplate -eq 115 -and $_.Hidden -eq $false}
#Export Form Libraries Inventory to CSV
If($FormLibraries.count -gt 0)
{
Write-host "`tFound '$($FormLibraries.count)' Form Librarie(s)!" -f Green
$FormLibraries | Select Title, DefaultViewUrl, Created | Export-Csv -Path $CSVPath -NoTypeInformation -Append
}
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
}
#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$CSVPath = "C:\Temp\FormLibs.csv"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get All Webs in the site collection and Iterate through
$Webs = Get-PnPSubWeb -Recurse -IncludeRootWeb
#Delete the Output Report if exists
If (Test-Path $CSVPath) { Remove-Item $CSVPath }
ForEach($Web in $Webs)
{
#Call the function
Get-PnPFormLibraries -Web $Web -CSVPath $CSVPath
}
This PowerShell script scans and extracts InfoPath Form libraries present in a given site collection and all its subsites. To scan for Infopath libraries in all sites of the tenant, use the following:
#Parameters
$Domain = "CrescentIntranet" #Your Domain Name in SharePoint Online. E.g. https://Crescent.sharepoint.com
$CSVPath = "C:\Temp\InfoPathRpt.csv"
$Cred = Get-Credential
#Frame Tenant URL and Tenant Admin URL
$TenantURL = "https://$Domain.SharePoint.com"
$TenantAdminURL = "https://$Domain-Admin.SharePoint.com"
#Function to Get Form Libraries
Function Get-PnPFormLibraries
{
[cmdletbinding()]
param(
[parameter(Mandatory = $true, ValueFromPipeline = $False)]$Web,
[parameter(Mandatory = $False, ValueFromPipeline = $False)][String] $CSVPath
)
Try {
Write-host "`tSearching Web '$($Web.URL)'" -f Yellow
#Get All Form libraries
$Lists= Get-PnPProperty -ClientObject $Web -Property Lists
$FormLibraries = $Lists | Where-Object {$_.BaseTemplate -eq 115 -and $_.Hidden -eq $false}
#Export Form Libraries Inventory to CSV
If($FormLibraries.count -gt 0)
{
Write-host "`tFound '$($FormLibraries.count)' Form Librarie(s)!" -f Green
$FormLibraries | Select Title, DefaultViewUrl, Created | Export-Csv -Path $CSVPath -NoTypeInformation -Append
}
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
}
#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
#Get All Site collections - Exclude BOT, Video Portals and MySites
$Sites = Get-PnPTenantSite -Filter "Url -like $TenantURL -and Url -notlike '-my.sharepoint.com/' -and Url -notlike '/portals/'"
#Iterate through all site collections
$Sites | ForEach-Object {
#Connect to each site collection
Connect-PnPOnline -Url $_.URL -Credentials $Cred
Write-host "`nProcessing Site Collection:"$_.URL -ForegroundColor Magenta
#Get All Webs in the site collection and Iterate through
Get-PnPSubWeb -Recurse -IncludeRootWeb | ForEach-Object {Get-PnPFormLibraries -Web $_ -CSVPath $CSVPath}
}
Here is another article to get all info Path forms in SharePoint On-premises: PowerShell to Find All InfoPath Form Libraries in SharePoint
When running this script, it does not capture the URL’s for me, anything I may be missing?
Thanks for the script. The base template 115 is for form libraries. How to get the list of all InfoPath forms on lists.I tried the base template 100 for this. But it got all the normal SharePoint lists too.
Refer this post to get a list of list templates and IDs: SharePoint Online: Get List Templates, IDs using PowerShell