Create New Custom List in SharePoint using PowerShell

Requirement: Add custom list to SharePoint using PowerShell.

create a sharepoint list using powershell

PowerShell to Create a New List in SharePoint:

To create a new list or library in a SharePoint Online site, you must have the “Manage Lists” permission! The default permission levels Edit, Design, Manage Hierarchy, and Full Control contain this permission. So in order to create lists or libraries, you need to have at least one of these permission levels. Here is the PowerShell script to create a new list in SharePoint.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Function to create a custom list
Function Create-List($SiteURL, $ListName)
    #Set the Error Action
    $ErrorActionPreference = "Stop"

    Try {
        $Web = Get-SPWeb -Identity $SiteURL
        $ListTemplate = [Microsoft.SharePoint.SPListTemplateType]::GenericList
        #Check if List with specific name exists
        if($Web.Lists.TryGetList($ListName) -eq $null)
            $List = $Web.Lists.Add($ListName, $ListName, $ListTemplate)  
            write-host "List Created Successfully!" -ForegroundColor Green
            write-host "List with a specific name already exists!" -ForegroundColor Red
    catch {
        Write-Host $_.Exception.Message -ForegroundColor Red
    finally {
        #Reset the Error Action to Default
        $ErrorActionPreference = "Continue"

#Parameters to create a new List
$ListName = "Customer Directory"

#Call the function to create a new custom list
Create-List $SiteURL $ListName

This PowerShell script creates a new custom list in SharePoint with the “Title” column. If you want to add more columns to the list using PowerShell, Refer: How to Add Fields to SharePoint List using PowerShell.

Salaudeen Rajack

Information Technology Professional with Two decades of SharePoint Experience.

Leave a Reply