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.

Figure 1

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

}


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s