SharePoint 2010: How to Create a Form Library Using a PowerShell Script

SharePoint 2010: How to Create a Form Library Using a PowerShell Script

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")functionGetHelp(){$HelpText=@"
DESCRIPTION:
This script will create a form library.
"@$HelpText}functionRahulFormLibraryCreation(){write-host"This script will create a form library for you"write-host"Please enter your site url"$siteURL=read-hostwrite-host"Please enter name of the form library"$library=read-hostwrite-host"Please enter description of your form library"$desctiption=read-host$site=New-ObjectMicrosoft.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}