Table of contents
TOC
Collapse the table of content
Expand the table of content

Add-PnPField

Bert Jansen|Last Updated: 2/20/2017
|
1 Contributor

Adds a field to a list or as a site column

Syntax

Add-PnPField [-AddToDefaultView [<SwitchParameter>]]
             [-Required [<SwitchParameter>]]
             [-Group <String>]
             [-Web <WebPipeBind>]
Add-PnPField -List <ListPipeBind>
             -Field <FieldPipeBind>
             [-Web <WebPipeBind>]
Add-PnPField -DisplayName <String>
             -InternalName <String>
             -Type <FieldType>
             [-List <ListPipeBind>]
             [-Id <GuidPipeBind>]
             [-AddToDefaultView [<SwitchParameter>]]
             [-Required [<SwitchParameter>]]
             [-Group <String>]
             [-Web <WebPipeBind>]
             [-Choices <String[]>]
Add-PnPField -DisplayName <String>
             -InternalName <String>
             -Type <FieldType>
             [-Id <GuidPipeBind>]
             [-Web <WebPipeBind>]
             [-Choices <String[]>]

Returns

Microsoft.SharePoint.Client.Field

Parameters

ParameterTypeRequiredDescription
DisplayNameStringTrueThe display name of the field
FieldFieldPipeBindTrueThe name of the field, its ID or an actual field object that needs to be added
InternalNameStringTrueThe internal name of the field
TypeFieldTypeTrueThe type of the field like Choice, Note, MultiChoice
AddToDefaultViewSwitchParameterFalseSwitch Parameter if this field must be added to the default view
ChoicesString[]FalseSpecify choices, only valid if the field type is Choice
GroupStringFalseThe group name to where this field belongs to
IdGuidPipeBindFalseThe ID of the field, must be unique
ListListPipeBindFalseThe name of the list, its ID or an actual list object where this field needs to be added
RequiredSwitchParameterFalseSwitch Parameter if the field is a required field
WebWebPipeBindFalseThe web to apply the command to. Omit this parameter to use the current web.

Examples

Example 1

PS:> Add-PnPField -List "Demo list" -DisplayName "Location" -InternalName "SPSLocation" -Type Choice -Group "Demo Group" -AddToDefaultView -Choices "Stockholm","Helsinki","Oslo"

This will add a field of type Choice to the list "Demo List".

Example 2

PS:>Add-PnPField -List "Demo list" -DisplayName "Speakers" -InternalName "SPSSpeakers" -Type MultiChoice -Group "Demo Group" -AddToDefaultView -Choices "Obiwan Kenobi","Darth Vader", "Anakin Skywalker"

This will add a field of type Multiple Choice to the list "Demo List". (you can pick several choices for the same item)

© 2017 Microsoft