Skip to content

Add site column to document library (Add-PnPField) #1722

Answered by LeonArmston
KrisVG-CRS asked this question in Q&A
Discussion options

You must be logged in to vote

@KrisVG-CRS

Would something like this do it:

Connect-PnPOnline -url "https://contoso.sharepoint.com/sites/marketing" -Credentials 'user@domain.com' 


#Define variables
$ColumnDisplayName = "ChoiceTest05"
$ColumnInternalName = "ChoiceTest0501"
$Choices = "Choice 05.1", "Choice 05.2", "Choice 05.3"
$ListName = "Documents"
$contentTypeName = "MyContentType01"
$viewName = "All Documents"

$Context = Get-PnPContext

#Add site column
Add-PnPField -DisplayName $ColumnDisplayName -InternalName $ColumnInternalName -Type Choice -Choices $Choices

#Add content types to the column

#Creates Content Type
$ct = Get-PnPContentType -Identity "Document"
$contentType = Add-PnPContentType -Name $contentTyp…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@KrisVG-CRS
Comment options

Answer selected by KrisVG-CRS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants