Hi,
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.
Hence 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 }
I hope this will help you out.
Thanks,
Rahul Rashu
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.
Hence 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 }
I hope this will help you out.
Thanks,
Rahul Rashu
No comments:
Post a Comment