Nov 14

Create SharePoint List Dynamically using Powershell Script

Create SharePoint List Dynamically using Powershell Script

In this post we will see how to create Sharepoint List dynamically using powershell script .

Please note that you can use notepad++ to write powershell scripts and save them with extension “.ps1”.

There are few variables which you need to assign some value e.g. site url and list name etc.
I would recommend to create this type of variables out side the function as I’ve done here.
Reason being is simple, you can use this variable in other functions in your script file.
Also, to make it workable we will add powershell Snap-in as mentioned in my last post.


Line $spTemplate = $web.ListTemplates[“Custom List”] defines under which template we want our new list to be added.
In this example we are adding it to Custom List.

$spListCollection=$web.Lists will retrieve collection of existing sites and assign it to a variable.

$spListCollection.Add($ListName,$ListName,$spTemplate) will add a new list to Custom List template.

Now, I will explain how to Save and Execute this script.

Save this script with name e.g “CreateList.ps1”
To execute this open powershell management as administrator.
Goto the location where you saved your script
Type following command which will execute your script
PS C:> .CreateList.ps1

To check your list go to site contents and look for the list with name “myList”.

Permanent link to this article:

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.