SharePoint Online: Create Multiple Lists from a CSV File using PowerShell

Requirement: Bulk create list or document library in SharePoint Online from a CSV File.

How to Create Multiple lists from CSV File?

PowerShell makes it easy to create multiple lists in SharePoint Online! This article will show you how to use PowerShell to create multiple lists from a CSV file in SharePoint Online. This can be useful if you need to quickly create multiple lists with predefined configurations from the CSV. The CSV file will be parsed, and the lists will be provisioned based on the column headings in the file, such as List Name, Description, Template, etc., in the file.

We can use the combination of CSV and PowerShell to create multiple lists in bulk in SharePoint Online. Here is my CSV File:

sharepoint online create list from csv

Note here the “Template” column defines the list template. It can be a Custom List, Tasks, Contact, Document Library, etc. You can download this CSV here:

PowerShell to Create Multiple lists from CSV File

Use this PnP PowerShell to create SharePoint lists from CSV. How to create multiple document libraries in SharePoint Online? Just set the CSV template accordingly!

#Set Parameters
$SiteURL = ""
$CSVFilePath = "C:\Documents\ListCreationTemplate.csv"
#Connect to the site
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the data from CSV file
$CSVFile = Import-CSV $CSVFilePath
#Read CSV file and create List
ForEach($Row in $CSVFile)
    Try {
        #Create List
        Write-host -f Yellow "Creating List:"$Row.ListName
        If($Row.OnQuickLaunch -eq "True")
            New-PnPList -Title $Row.ListName -Template $Row.Template -OnQuickLaunch -ErrorAction Stop | Out-Null
            New-PnPList -Title $Row.ListName -Template $Row.Template -ErrorAction Stop | Out-Null
        Write-host -f Green "`tCreated List '$($Row.ListName)'"
    Catch {
        write-host -f Red "`tError:" $_.Exception.Message

This CSV file has ListName, Description, Template, OnQuickLaunch columns. You can add any necessary columns as the parameter for creating list.

Tail: How to Get All Values from an Enumerator?

If you want to get all values from an enum, use the below PowerShell script. In my case, I had to retrieve all list template types.

#Get All Values from the Enum
Function Get-EnumValues([string]$Enumerator)
    $EnumValues = @{}
    [Enum]::GetValues([Type]$Enumerator) | ForEach-Object {
        $EnumValues.add($_, $_.value__)
Get-EnumValues -Enumerator "Microsoft.SharePoint.Client.ListTemplateType"

You can also use GetEnumValues() method of the enumerator. E.g.


Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *