Yes/No Column PnP PowerShell

PnP PowerShell: Create Multiple Line of Text Site Column in SharePoint Online

SharePoint Online serves as a robust platform for collaboration, document management, and data organization. Part of its flexibility comes from the ability to create custom site columns, which facilitate structured data storage. In this blog post, we will delve into the process of creating a multiple lines of text site column in SharePoint Online using the PnP PowerShell module.

Understanding PnP PowerShell

PnP PowerShell is a command-line interface offered by the SharePoint Patterns and Practices (PnP) initiative. It empowers administrators and developers to interact with SharePoint Online through PowerShell scripting. PnP PowerShell simplifies various tasks, including site provisioning, customization, and data management.

Prerequisites

Before we begin, make sure you have the following prerequisites in place:

  1. SharePoint Online environment with administrative access.
  2. PnP PowerShell module installed. If you haven’t installed it yet, you can do so by referring to my another blog post available at: https://www.hemantkabra.in/microsoft-sharepoint/pnp-powershell-how-to-get-started

Here is the Step-by-Step Guide to create a Multiple Lines of Text Site Column in SharePoint Online

Step 1: Connect to SharePoint Online

Use the Connect-PnPOnline command to establish a connection with your SharePoint Online environment. Provide the URL of your SharePoint site and your credentials:

Connect-PnPOnline -Url https://yourtenant.sharepoint.com/sites/yoursite -Interactive

Step 2: Create the Multiple Lines of Text Site Column

Let’s proceed to create the multiple lines of text site column utilizing the Add-PnPField and Add-PnPFieldFromXml command. You can specify the display name, internal name, and other attributes of the column as needed:

# Define the column properties
$columnName = "YourColumnName"
$columnDisplayName = "Your Column Display Name"
$columnGroup = "Your Column Group" # Optional: You can group columns together for better organization.

# Create the Multiple Lines of Text Site Column
Add-PnPField -Type Note -DisplayName $columnDisplayName -InternalName $columnName -Group $columnGroup

To create the column in a specific list, you can use below mentioned code:

# Define the column properties
$columnName = "YourColumnName"
$columnDisplayName = "Your Column Display Name"
$columnGroup = "Your Column Group" # Optional: You can group columns together for better organization.
$ListName = "YourListName"

# Create the Multiple Lines of Text List Column
Add-PnPField -Type Note -List $ListName -DisplayName $columnDisplayName -InternalName $columnName -Group $columnGroup -AddToDefaultView

You can also add a multiple line of text column to SharePoint Online List using the XML schema as shown in below code:

$ListName = "YourListName"

# Define XML Schema
$FieldXML= "<Field Type='Note' Name='YourColumnName' ID='$([GUID]::NewGuid())' DisplayName='Your Column Display Name' Required ='True' RichText='TRUE' RichTextMode='FullHtml' ></Field>"
 
# Add the Column to the SharePoint Online List
Add-PnPFieldFromXml -FieldXml $FieldXML -List $ListName

In the above all the examples,

  • Replace “YourColumnName” with the internal name you want to assign to the column. It should be unique and not contain spaces.
  • Replace “Your Column Display Name” with the user-friendly display name you want to show for the column.
  • Replace “Your Column Group” with the name of the column group. You can omit this line if you don’t want to group the column.
  • Replace “YourListName” with the internal name of the SharePoint Online List.

Explanation of the parameters:

  • -DisplayName: The display name of the site column that will be visible to users.
  • -InternalName: The internal name of the site column used for internal references. It must be unique and not contain spaces.
  • -Type: The type of the site column. For a Single Line of Text column, we use “Note”.
  • -Group: The name of the column group where the site column will be added. You can use an existing group or create a new one.
  • -List: The name of the SharePoint Online list where the site column will be added.
  • -AddToDefaultView: Adds the column to the Default List View of the SharePoint Online List

Step 3: Verify the Column Creation

To verify the successful creation of the column, navigate to the settings of your SharePoint site and review the list of site columns.

You can also use the PnP PowerShell to verify the newly created column using the below mentioned code:

Get-PnPSiteColumn -Identity $columnName

This command will display the details of the newly created site column, including its name, display name, and other properties.

Conclusion

Creating a multiple lines of text site column in SharePoint Online using PnP PowerShell is an uncomplicated process that enriches your SharePoint environment with the capability to capture and display extended text content. PnP PowerShell’s efficiency streamlines the creation and customization of columns, enabling efficient management of your SharePoint sites.

By mastering PnP PowerShell, you unlock the potential to enhance and tailor your SharePoint Online experience, whether you’re an administrator seeking to optimize workflows or a developer aiming to extend platform capabilities. The ability to seamlessly create multiple lines of text site columns underscores the power of PnP PowerShell in extending the functionality of SharePoint Online.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *