Someone expressed his needs to have a PowerShell script to create FormLibrary. Hence I have written the below script and it works in both SharePoint 2007 and SharePoint 2010. This code can be further modified to create other types of libraries as well.

I am sharing my code here:
param([switch]$help)             
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")            
             
function GetHelp() {            
$HelpText = @"
DESCRIPTION:
This script will create a form library.
"@            
$HelpText            
}            
             
function RahulFormLibraryCreation() {             
    write-host "This script will create a form library for you"            
    write-host "Please enter your site url"            
    $siteURL = read-host            
    write-host "Please enter name of the form library"            
    $library = read-host            
    write-host "Please enter description of your form library"            
    $desctiption = read-host            
    $site = New-Object Microsoft.SharePoint.SPSite($siteURL)            
    $web = $site.OpenWeb()            
    $template = [Microsoft.Sharepoint.SPListTemplateType]::XMLForm            
    $web.Lists.Add($library,$description,$template)            
    $site.Dispose()            
    $web.Dispose()             
}            
if($help) { GetHelp; Continue }            
else { RahulFormLibraryCreation }

Other Languages

This article is also available in the following languages: