Pages

Wednesday, February 21, 2018

Create SharePoint Online Lists and Fields using PnP PowerShell

Introduction

In this blog post we will be looking how to create Lists and Fields using PnP PowerShell. You can download and install PnP PowerShell here.

Solution

First you have to connect to SharePoint Online using PnP PowerShell.

Connect-PnPOnline –Url “site collection name” –Credentials (Get-Credential)

Creating List

Generic List

$ListName = "Cohort"

$ListUrl = "Lists/Cohort"

New-PnPList -Title "ListName" -Url "ListUrl" -Template GenericList 

Fields

Number

  

$NumberFieldString =''
Add-PnPFieldFromXml -List ListName -FieldXml $NumberFieldString 

Text

  

$TextFieldString =''
Add-PnPFieldFromXml -List ListName -FieldXml $TextFieldString 

Date

  

$DateFieldString = ''
Add-PnPFieldFromXml -List $ListName -FieldXml $EndDateFieldString 

Multi Lines

  

$MultiLines =''
Add-PnPFieldFromXml -List $InstructorCohortListName -FieldXml $MultiLines

Yes/No

  

$Boolean =''
Add-PnPFieldFromXml -List $InstructorCohortListName -FieldXml $Boolean 

Lookup

  
#Please not that you have to give the Look up list guid for List Field
$Lookup =''
Add-PnPFieldFromXml -List $CohortListName -FieldXml $Lookup 

No comments:

Post a Comment