2

I have to scan my SharePoint environment to check how many of the sites have custom Infopath forms and Workflows (OOB or SPDesigner).

I am planning to use PowerShell to scan my sites/subsites. Do you know how could i get the information on the Infopath and Workflows?

Any thoughts?

2 Answers 2

3

Here is a PowerShell script for that exact purpose. It will output an excel file that contains all InfoPath Forms and Workflows within the specified Web Application.

# Find InfoPath Forms in the SharePoint Farm

Write-Host "Get InfoPath Forms and Workflows"

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition 
$webApp = Get-SPWebApplication -Identity https://webappurlhere.com
$outputObj = @() 

foreach ($site in $webApp.Sites) {
        foreach($web in $site.AllWebs) {
                for($i = 0; $i -ne $web.lists.count; $i++) {
                        $list = $web.Lists[$i]
                        if ($list.BaseTemplate -eq "XMLForm" -and $list.BaseType -eq "DocumentLibrary") {
                                $FORM = New-Object PSObject
                                $FORM | Add-Member NoteProperty Type "Form" 
                                $FORM | Add-Member NoteProperty Site $($List.ParentWeb.Title)
                                $FORM | Add-Member NoteProperty URL $($List.ParentWeb.URL)
                                $FORM | Add-Member NoteProperty Title $($List.Title)
                                $outputObj += $FORM
                        }
                       foreach ($wf in $list.WorkflowAssociations)
                       {
                              if ($wf.Enabled) {
                                  $WORKFLOW = New-Object PSObject 
                                  $WORKFLOW | Add-Member NoteProperty Type "Workflow" 
                                  $WORKFLOW | Add-Member NoteProperty Site $($List.ParentWeb.Title)
                                  $WORKFLOW | Add-Member NoteProperty URL $($List.ParentWeb.URL)
                                  $WORKFLOW | Add-Member NoteProperty Title $($List.Title)
                                  $WORKFLOW | Add-Member NoteProperty WorkflowName $($wf.Name)
                                  $WORKFLOW | Add-Member NoteProperty BaseTemplate $($wf.BaseTemplate)
                                  $WORKFLOW | Add-Member NoteProperty AssociationData $($wf.AssociationData)
                                  $outputObj += $WORKFLOW
                          }
                    }
            }
    }

}

$outputObj | Export-CSV -Path $scriptPath\InfoPathForms.csv -NoTypeInformation
1
  • To prevent memory leaks, don't forget to dispose of the $web and $site objects before the end of the foreach blocks in which they are defined.
    – Thriggle
    Feb 1, 2017 at 19:52
1

While this answer does great for finding InfoPath Forms based on Document Library types not so much for Lists with custom InfoPath Forms enabled, for this use this script:

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


#Read more: http://www.sharepointdiary.com/2016/01/find-all-infopath-list-forms-in-sharepoint-using-powershell.html#ixzz5BdHWOyPs

As for workflows Dr. Quinn's answer works great, you will most likely need to run both scripts for a complete set of Forms and Workflows.

Happy SharePointing.

SG.

1
  • 1
    works like a charm! thanks for this answer! Apr 2, 2019 at 12:10

Your Answer

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

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