PnP PowerShell provides a lot of commands to make tasks easier against SharePoint Objects. And, some of the commands (like Add-PnPField & Add-PnPFieldXml) are used to add different types of columns to SharePoint.
In this blog, I have provided different examples for creating Multi-Line Text Columns as Site Column, Column in a List, and Column in a Content Type using PnP PowerShell command.
Before running the add-PnPField commands, we have to connect the SharePoint site using Connect-PnPOnline command.
- $cred = Get-Credential
- Connect-PnPOnline -Url https:
Add Multiline Text Column to List
The following command adds the multiline text column "Remarks" to the Test List.
- Add-PnPField -DisplayName 'Remarks' -InternalName 'Remarks' -Type Note -List 'Test List'
Add Multiline Text Column to Web
The following command is used to add the multiLine text column "Remarks" as a Site Column to the web.
- Add-PnPField -DisplayName 'Remarks' -InternalName 'Remarks' -Type Note
Add Multiline Text Column to ContentType
The following command adds the "Remarks" column as a site column and then it's added to the Site ContentType.
- $field = Add-PnPField -DisplayName 'Remarks' -InternalName 'Remarks' -Type Note
- Add-PnPFieldToContentType -Field $field -ContentType 'Content Type Name'
Add Multiline Text Column to Web using Xml
The following command adds the multi line text column "Remarks" as a site column based on the XML.
- $guid = New-Guid
- $xml = '<Field Type="Note" Name="Remarks" DisplayName="Remarks" ID="{'+$guid.Guid+'}" Group="PnP Columns" AllowDeletion="TRUE" />'
- Add-PnPFieldFromXml -FieldXml $xml
Add Multiline Text Column to List using Xml
The following command adds the multiline text column "Remarks" to the Test List based on the XML.
- $guid = New-Guid
- $xml = '<Field Type="Note" Name="Remarks" DisplayName="Remarks" ID="{'+$guid.Guid+'}" Group="PnP Columns" AllowDeletion="TRUE" />'
- Add-PnPFieldFromXml -FieldXml $xml -List 'Test List'
Add Multiline Text Column to ContentType using Xml
The following command adds the multiline text column "Remarks" as a site column based on the XML. And then, adds that field to the content type.
- $guid = New-Guid
- $xml = '<Field Type="Note" Name="Remarks" DisplayName="Remarks" ID="{'+$guid.Guid+'}" Group="PnP Columns" AllowDeletion="TRUE" />'
- Add-PnPFieldFromXml -FieldXml $xml
- Add-PnPFieldToContentType -Field $field -ContentType 'Content Type Name'
Add Multiline Text Column as a Required Column
The following command adds the field "Remarks" as a required column to the Test List.
- Add-PnPField -DisplayName 'Remarks' -InternalName 'Remarks' -Type Note -List 'Test List' -Required $true