PowerShell tip to Identify lists with InfoPath Forms associated in SharePoint 2016 by using the Property “_ipfs_infopathenabled”

Sathish Nadarajan
 
Solution Architect
February 15, 2018
 
Rate this article
 
Views
4435

 

To identify whether a list is associated with InfoPath Form or not, we have a Property called _ipfs_infopathenabled, which will have a value of True. If the list is not attached, the property itself will not be available.

And specifically, the infopath can be associated to any of the content type. Hence, we need to iterate through the content types in the list and identify whether any of the content type is having the property or not.

 function AddPowerShellSnapin()
 {
     try
     {
         Add-PSSnapin "Microsoft.SharePoint.PowerShell"
         Write-Host "Adding PowerShell Snap-in" -ForegroundColor Yellow
         # Try to get the PowerShell Snappin.  If not, then adding the PowerShell snappin on the Catch Block
         Get-PSSnapin "Microsoft.SharePoint.PowerShell" 
     }
     catch
     {
         if($Error[0].Exception.Message.Contains("No Windows PowerShell snap-ins matching the pattern 'Microsoft.SharePoint.PowerShell' were found"))
         {
             Add-PSSnapin "Microsoft.SharePoint.PowerShell"
         }
     }
     
     Write-Host "Finished Adding PowerShell Snap-in" -ForegroundColor Green
     
 }
 
 function IsInfoPathUsed($List)
 {
     $InfoPath_Used = "False"   
         
     foreach($contentType in $list.ContentTypes)
 	{
 		$InfoPath_Used = $contentType.ResourceFolder.Properties[“_ipfs_infopathenabled”]
 		if($InfoPath_Used -eq "True")
 		{
 			break;
 		}
 	}	
     
     return $InfoPath_Used
 }
 
 AddPowerShellSnapin
 
 $Web =  Get-SPWeb "http://sathishserver:555/sites/developersite"
          
         # Get the Lists    
         $Lists = $Web.Lists
         
         # Iterate through the Lists
         foreach($List in $Lists)
         {
             write-Host "Get Lists With InfoPath in -" + $List.Title
              
                 $IsInfoPathUsed = IsInfoPathUsed($List)
                 if($IsInfoPathUsed -eq "True")
                 {
                     $output = $_.SiteCollectionURL + "," + $Web.Url + "," + $List.Title + "," + $List.DefaultViewUrl 
                     Add-Content $ListsWithInfoPath_CSV_Path $output
                 }
           } 
 

Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment