Collaborate, Innovate, Automate

Add Multiple Document Libraries

This PnP PowerShell script reads a list of library names from a CSV file and bulk creates multiple SharePoint Online document libraries on a target site in a single operation. Each library is added to the Quick Launch navigation automatically.

Purpose

This script helps with document library provisioning by:

Prerequisites

CSV File Format

The script expects a CSV file with a single column:

CSV file format showing LibraryName column

PowerShell Script

# Set Parameters
$SiteURL = "https://tenantName.sharepoint.com/sites/siteName"
$CSVPath = "C:\yourPath\DocumentLibs.csv"

# Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

# Read the CSV file
$Libraries = Import-Csv -Path $CSVPath

# Loop through each library name
foreach ($Library in $Libraries) {
    $LibraryName = $Library.LibraryName

    # Create document library
    New-PnPList -Title $LibraryName -Template DocumentLibrary -OnQuickLaunch

    Write-Host "Created library: $LibraryName"
}

Write-Host "Completed"

Usage Notes