PowerShell script for creating SharePoint Document Library

Kumarmaddu
Posted by Kumarmaddu under PowerShell category on | Points: 40 | Views : 984
Hi..
The following script is used to create ShrePoint document library through PowerShell

Add-PSSnapin Microsoft.SharePoint.Powershell

# varable description
$webUrl = "Site Name"
$web = Get-SPWeb $webUrl
$libraryName = "Library Name"
$libraryDescription = "Library description"
$libraryTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary;

# Adding Library
try
{
$web.Lists.Add($libraryName,$libraryDescription,$libraryTemplate);
$web.Update();
}
catch
{
write-host "Error" $_.exception
$errorlabel = $true
}

finally
{
if($web -ne $null)
{
$web.Dispose()
}
}

Thank You...

Comments or Responses

Login to post response