Share via


SharePoint 2013: Create and Delete a List using PowerShell

This is a quick article that demonstrates creating a SharePoint list, adding items to a list, and deleting a list using PowerShell.

Creating a list

Add-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue            
$SPweb = Get-SPWeb -Identity 'http://Sp2013'            
$ListTemplate = $SPweb.ListTemplates['Custom List']            
$SPweb.Lists.Add('SharePoint', 'List creation demo using PowerShell' , $ListTemplate)

Adding items to a list

Add-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue            
$SPweb = Get-SPWeb -Identity 'http://Sp2013'            
$list = $SPweb.Lists['SharePoint']            
$item1 = $list.Items.Add()            
$item1['Title'] = 'Chendrayan'            
$item1.update()

Removing a list

Add-PSSnapin 'Microsoft.SharePoint.PowerShell' -ErrorAction SilentlyContinue            
$SPweb = Get-SPWeb -Identity 'http://Sp2013'            
$list = $SPweb.Lists['SharePoint']            
$item1 = $list.Items            
$item1[0].Delete()