Skip to content

Instantly share code, notes, and snippets.

@expiscornovus
Created November 21, 2021 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save expiscornovus/782b7d9c43269f2bffe3518edd9b45de to your computer and use it in GitHub Desktop.
Save expiscornovus/782b7d9c43269f2bffe3518edd9b45de to your computer and use it in GitHub Desktop.
Create list for Course registration
<# .SYNOPSIS
Create list for Course registration.
.DESCRIPTION
You need to have the latest version of PnP PowerShell
Create list for Course registration.
.PARAMETER SiteCollection
Specifies the site collection Url of the SharePoint Online environment.
.PARAMETER ListName
Specifies the name of the SharePoint Online list.
.NOTES
Author:
Expiscornovus
Current Version:
0.1
Version History:
0.1 - First minor version
.EXAMPLE
PS> .\create_courseregistration_spolist.ps1 -SiteCollection "https://contoso.sharepoint.com/sites/formatting" -ListName "Courses"
#>
param ([Parameter(Mandatory)]$SiteCollection,[Parameter(Mandatory)]$ListName)
Connect-PnPOnline -Url $SiteCollection -Interactive
New-PnPList -Title $ListName -Template GenericList
Add-PnPField -List $ListName -DisplayName "Registration End Date" -InternalName "RegistrationEndDate" -Type DateTime
Add-PnPField -List $ListName -DisplayName "Course Date" -InternalName "CourseDate" -Type DateTime
Add-PnPField -List $ListName -DisplayName "Register" -InternalName "Register" -Type Text
Add-PnPField -List $ListName -DisplayName "Number of Available Places" -InternalName "NumberofPlaces" -Type Number
Add-PnPFieldFromXml -List $ListName -FieldXml '<Field Type="UserMulti" DisplayName="People Who Registered" UserSelectionMode="PeopleOnly" StaticName="PeopleWhoRegistered" Name="PeopleWhoRegistered" Mult="TRUE" />'
Add-PnPView -List $ListName -Title "All Courses" -Fields "Title","RegistrationEndDate","CourseDate","Register","NumberofPlaces","PeopleWhoRegistered"
Disconnect-PnPOnline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment