Add-PnPField

Tip

We encourage you to make improvements to this documentation. Please navigate to https://github.com/pnp/powershell/blob/dev/documentation/Add-PnPField.md to change this file.

Add a field

Syntax

Add-PnPField
   [-List <ListPipeBind>]
   -DisplayName <String>
   -InternalName <String>
   -Type <FieldType>
   [-Id <Guid>]
   [-AddToDefaultView]
   [-Required]
   [-Group <String>]
   [-ClientSideComponentId <Guid>]
   [-ClientSideComponentProperties <String>]
   [-Connection <PnPConnection>]
   [<CommonParameters>]
Add-PnPField
   -List <ListPipeBind>
   -Field <FieldPipeBind>
   [-Connection <PnPConnection>]
   [<CommonParameters>]
Add-PnPField
   -DisplayName <String>
   -InternalName <String>
   -Type <FieldType>
   [-Id <Guid>]
   [-ClientSideComponentId <Guid>]
   [-ClientSideComponentProperties <String>]
    [-Connection <PnPConnection>]
   [<CommonParameters>]
Add-PnPField
   [-AddToDefaultView]
   [-Required]
   [-Group <String>]
    [-Connection <PnPConnection>]
   [<CommonParameters>]

Description

Adds a field (a column) to a list or as a site column. To add a column of type Managed Metadata use the Add-PnPTaxonomyField cmdlet.

Examples

EXAMPLE 1

Add-PnPField -Type Calculated -InternalName "C1" -DisplayName "C1" -Formula ="[Title]"

Adds a new calculated site column with the formula specified

EXAMPLE 2

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 3

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)

Parameters

-AddToDefaultView

Switch Parameter if this field must be added to the default view

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ClientSideComponentId

The Client Side Component Id to set to the field

Type:Guid
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ClientSideComponentProperties

The Client Side Component Properties to set to the field

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:PnPConnection
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DisplayName

The display name of the field

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Field

The name of the field, its ID or an actual field object that needs to be added

Type:FieldPipeBind
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Group

The group name to where this field belongs to

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Id

The ID of the field, must be unique

Type:Guid
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InternalName

The internal name of the field

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-List

The name of the list, its ID or an actual list object where this field needs to be added

Type:ListPipeBind
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-Required

Switch Parameter if the field is a required field

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Type

The type of the field like Choice, Note, MultiChoice. For a complete list of field types visit https://docs.microsoft.com/dotnet/api/microsoft.sharepoint.client.fieldtype

Type:FieldType
Accepted values:Invalid, Integer, Text, Note, DateTime, Counter, Choice, Lookup, Boolean, Number, Currency, URL, Computed, Threading, Guid, MultiChoice, GridChoice, Calculated, File, Attachments, User, Recurrence, CrossProjectLink, ModStat, Error, ContentTypeId, PageSeparator, ThreadIndex, WorkflowStatus, AllDayEvent, WorkflowEventType, Geolocation, OutcomeChoice, Location, Thumbnail, MaxItems
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False