After creating an administrator approved InfoPath form, the administrator is required to verify, upload and active the form prior to it becoming available. Through the SharePoint UI, you have to manually handle each of these operations separately on each file. Using PowerShell and the SPInfoPathForTemplate cmdlets, you can care of these tasks in a simple script.
In the following script, we Verify, Upload, Activate, and set the Category on three forms that are listed in a text file.
Step #1 – Create a File
Create a text file with the forms you want to perform these actions on.
Step #2 – PowerShell
# Set the required variables
$siteURL = “http://lab.ps4sp.com”
$settingsFile = “c:scriptsInfoPathFormsList.txt”
$category = “PS4SP”
foreach ($i in Get-Content -Path $settingsFile)
$formLocation = “c:Forms$i.xsn”
# Verify the InfoPath form
Write-Output “Verifying ” $i
Test-SPInfoPathFormTemplate -Path $formLocation
# Upload the InfoPath form
Write-Output “Uploading ” $i
Install-SPInfoPathFormTemplate -Path $formLocation
# Activate the InfoPath form
Write-Output “Activating ” $i
Enable-SPInfoPathFormTemplate -Identity $i -Site $siteURL
# Modify the category of the form
Set-SPInfoPathFormTemplate -Identity $formName -Category $category