Wednesday, April 3, 2013

Create Form Library in SharePoint using PowerShell

Requirement: Create form library in SharePoint using PowerShell.

Here is the SharePoint PowerShell script to create form library:

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

Function Create-FormLibrary 
{
 Param
 ( 
  [Microsoft.SharePoint.SPWeb]$Web,
  [String] $ListName,
  [String] $Description
 )
 #Get the Form Library template
 $ListTemplate = [Microsoft.Sharepoint.SPListTemplateType]::XMLForm
 
 #Check if the list already exists
 if( ($web.Lists.TryGetList($ListName)) -eq $null)
 {
  #Create the list
     $Web.Lists.Add($ListName,$Description,$ListTemplate) 
  
  #You can Set Properties of Library such as OnQuickLaunch, etc
  $FormLib = $Web.Lists[$ListName] 
  $FormLib.OnQuickLaunch = $true
  $FormLib.Update()
  
  Write-Host "Form library created successfully!"
 }
 else
 {
  Write-Host "Form library already exists!"
 }
 #Dispose web object
    $Web.Dispose()    
}

#Get the Web
$web = Get-SPWeb "http://sharepoint.crescent.com/contact-us/"

#Cal the function to create library
Create-FormLibrary $web "ContactUsForms" "Form Library to store Contact us Forms"



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...