How to Create a List using PowerShell in SharePoint Online

Prerequisites:

SharePoint Online Management Shell: https://www.microsoft.com/en-us/download/details.aspx?id=35588

PnP – PowerShell Cmdlets: https://github.com/officedev/pnp-powershell/releases

PowerShell Script:

Open SharePoint Online Management Shell and execute the following script.

  1. ## Connects to a SharePoint Site  
  2. Connect-SPOnline -Url https://c986.sharepoint.com -Credentials (Get-Credential)  
  3.   
  4. ## Creates a neww list  
  5. ## List Template Type: https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.client.listtemplatetype.aspx  
  6. ## Optional Parameters - OnQuickLaunch, EnableVersioning, EnableContentTypes  
  7. New-SPOList -Title "Custom Doc Library" -Url "CustomDocLibrary" -Template DocumentLibrary -OnQuickLaunch -EnableVersioning -EnableContentTypes    
  8.   
  9. ##Disconnects the context  
  10. Disconnect-SPOnline