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?
To get all form libraries in SharePoint Online site collection, use the below PowerShell script.
This script checks if the template ID of any list is 115 to decide 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 $FormLibraries = Get-PnPList -Web $Web | 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 } #Get All Subwebs $SubWebs = Get-PnPSubWebs -web $Web Foreach ($SubWeb in $SubWebs) { #Call the function recursively Get-PnPFormLibraries -Web $SubWeb -CSVPath $CSVPath } } 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 -UseWebLogin $Web = Get-PnPWeb #Delete the Output Report if exists If (Test-Path $CSVPath) { Remove-Item $CSVPath } #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:
#Parameters $Domain = "CrescentIntranet" #Your Domain Name in SharePoint Online. E.g. https://CrescentIntranet.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 = $True)]$Web, [parameter(Mandatory = $False, ValueFromPipeline = $False)][String] $CSVPath ) Try { Write-host "`tSearching Web '$($Web.URL)'" -f Yellow #Get All Form libraries $FormLibraries = Get-PnPList -Web $Web | 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 } #Get All Subwebs $SubWebs = Get-PnPSubWebs -web $Web Foreach ($SubWeb in $SubWebs) { #Call the function recursively Get-PnPFormLibraries -Web $SubWeb -CSVPath $CSVPath } } 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 $SiteConn = Connect-PnPOnline -Url $_.URL -Credentials $Cred -ReturnConnection Write-host "`nProcessing Site Collection:"$_.URL -f Yellow #Call the Function for site and all Subwebs Get-PnPWeb -Connection $SiteConn | Get-PnPFormLibraries -CSVPath $CSVPath Disconnect-PnPOnline -Connection $SiteConn }
Here is my another article to get all info Path forms in SharePoint On-premises: PowerShell to Find All InfoPath Form Libraries in SharePoint
No comments:
Please Login and comment to get your questions answered!