SharePoint Create Document Library Using PowerShell

cls
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell

# varable description
$webUrl = "
http://sp2010:8080/personal/Test1/"
$web = Get-SPWeb $webUrl
$libraryName = "My Document Library"
$libraryDescription = "Storage for Personal Documents"
$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()
}

}

Comments

  1. Wonderful article! This is the type of information that should
    be shared around the internet. Disgrace on the seek engines
    for now not positioning this publish higher! Come on over and consult with my
    website . Thanks =)

    Also visit my webpage - raspatory

    ReplyDelete

Post a Comment

Popular posts from this blog

C# Copy files from one server to another

Suppress StyleCop SA1600

Telerik Rad Grid Sorting