Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
    • Uncategorized
    • Uncategorized
  • PowerAutomate
Rishan Solutions
Latest Posts
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025
  • Using TRY_CAST vs CAST May 7, 2025
  • Dynamic SQL Execution with sp_executesql May 7, 2025

Automating SharePoint List Creation using PnP PowerShell

Posted on March 18, 2025March 18, 2025 by Rishan Solutions

Loading

Automating SharePoint List Creation using PnP PowerShell allows you to quickly deploy multiple lists with predefined columns, views, and permissions.

What you can do?

  • Create multiple lists automatically
  • Define columns and metadata
  • Set permissions and views

Step 1: Install and Import PnP PowerShell

If you haven’t installed PnP PowerShell, install it using:

Install-Module -Name PnP.PowerShell -Scope CurrentUser -Force

Then, import the module:

Import-Module PnP.PowerShell

PnP PowerShell is ready!


Step 2: Connect to SharePoint

Before creating lists, connect to your SharePoint Online site:

$SiteUrl = "https://yourtenant.sharepoint.com/sites/yoursite"
Connect-PnPOnline -Url $SiteUrl -Interactive

🔹 Replace yourtenant with your Microsoft 365 tenant name.
🔹 Replace yoursite with your SharePoint site name.

Connected to SharePoint!


Step 3: Create a New SharePoint List

To create a new SharePoint list:

$ListName = "Project Tasks"
$ListDescription = "A list to track project tasks"
$TemplateType = "GenericList" # Options: GenericList, DocumentLibrary, Announcements, Contacts, etc.

New-PnPList -Title $ListName -Template $TemplateType -Description $ListDescription -OnQuickLaunch

Write-Host "SharePoint List '$ListName' created successfully!"

🔹 This creates a custom list named “Project Tasks”.
🔹 Add -OnQuickLaunch to display it in the navigation bar.

List created successfully!


Step 4: Add Columns to the List

Now, let’s add columns to the “Project Tasks” list:

# Add a Text Column
Add-PnPField -List "Project Tasks" -DisplayName "Task Name" -InternalName "TaskName" -Type Text

# Add a Choice Column
Add-PnPField -List "Project Tasks" -DisplayName "Status" -InternalName "Status" -Type Choice -Choices "Not Started", "In Progress", "Completed"

# Add a Date Column
Add-PnPField -List "Project Tasks" -DisplayName "Due Date" -InternalName "DueDate" -Type DateTime

Write-Host "Columns added successfully!"

🔹 Supports column types like Text, Number, Choice, DateTime, Boolean, Lookup, User, Currency.

Columns added successfully!


Step 5: Create a Default View

Define a custom list view:

$ViewFields = @("TaskName", "Status", "DueDate") # Columns to show

Add-PnPView -List "Project Tasks" -Title "Active Tasks" -Fields $ViewFields -Paged -SetAsDefault

Write-Host "Default view created successfully!"

🔹 This sets up a custom default view with selected columns.

Custom view created successfully!


Step 6: Assign Permissions

To restrict access to the list:

$GroupName = "Project Team"
Set-PnPListPermission -Identity "Project Tasks" -Group $GroupName -AddRole "Edit"

Write-Host "Permissions assigned to $GroupName!"

Assigns Edit permissions to the “Project Team” group.

Permissions assigned successfully!


Step 7: Automate Multiple List Creation

To create multiple lists automatically, use a loop:

$Lists = @(
@{ Name="Projects"; Template="GenericList"; Description="List of all projects" },
@{ Name="Tasks"; Template="GenericList"; Description="List of tasks" },
@{ Name="Meetings"; Template="GenericList"; Description="List of meetings" }
)

foreach ($List in $Lists) {
New-PnPList -Title $List.Name -Template $List.Template -Description $List.Description -OnQuickLaunch
Write-Host "Created list: $($List.Name)"
}

Write-Host "All lists created successfully!"

Loops through an array and creates multiple lists in one go!

Multiple lists created successfully!


Step 8: Export and Import List Configurations

Export Existing List Configuration

If you want to replicate an existing list, export its structure:

Get-PnPSiteTemplate -Out "SiteTemplate.xml"
Write-Host "Site structure exported successfully!"

Import List Configuration to Another Site

To import the list structure to a new SharePoint site:

Apply-PnPSiteTemplate -Path "SiteTemplate.xml"
Write-Host "Site structure imported successfully!"

Easily copy lists from one site to another!


Step 9: Disconnect the Session

After automation, disconnect from SharePoint:

Disconnect-PnPOnline

Disconnected from SharePoint!

Posted Under PNP PowerShellList Automation Metadata Microsoft 365 Permissions PNP PowerShell PowerShell Scripts SharePoint online Site Templates

Post navigation

HTTP 408 – Request Timeout
Scheduling SharePoint Reports using PnP PowerShell

Leave a Reply Cancel reply

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

Recent Posts

  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN
  • Working with Hierarchical Data
  • Using TRY_CAST vs CAST

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
© Rishan Solutions 2025 | Designed by PixaHive.com.
  • Rishan Solutions