Tuesday, February 10, 2015

Create a Document Library in SharePoint using PowerShell

Create a document library in SharePoint 2013 using PowerShell.

PowerShell Script to Create New Document Library in SharePoint:
Here is how to create document library in SharePoint 2013 using PowerShell

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#PowerShell Fuction to Create a Document library in SharePoint 
Function Create-DocumentLibrary
  [String] $LibraryName,
  [String] $Description
    #Get the Document Library template
    $ListTemplate = [Microsoft.Sharepoint.SPListTemplateType]::DocumentLibrary
    #Check if the library already exists
    if(($web.Lists.TryGetList($LibraryName)) -eq $null)
        #Create the Library
        $Web.Lists.Add($LibraryName,$Description,$ListTemplate) > Null
        #Set Properties of Library such as OnQuickLaunch, etc
        $Library =  $Web.Lists[$LibraryName] 
        $Library.OnQuickLaunch = $true
        Write-Host "Document library created successfully!" -f Green
        Write-Host "Document Library '$LibraryName' already exists!" -f Red
#Get the Web
$web = Get-SPWeb "http://intranet.crescent.com/"
#Call the function to create library
Create-DocumentLibrary $web "Team Documents" "Library to Share Team Documents"
This PowerShell script creates a document library in SharePoint 2013.
sharepoint powershell create new document library

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

Check out these SharePoint products:


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...