SharePoint Online provides a powerful platform for collaboration and data management. One way to customize your lists and libraries is by creating custom columns. In this tutorial, we’ll focus on creating a Yes/No Site Column using PnP PowerShell.
Prerequisites
Before you begin, make sure you have the following:
- SharePoint Online Site: Ensure you have the necessary permissions to create columns.
- PnP PowerShell: Install the PnP PowerShell module if you haven’t already. Refer to another blog post on https://www.hemantkabra.in/microsoft-365/sharepoint-online/pnp-powershell-how-to-get-started/ for guidance on installing the PnP PowerShell Module.
Steps to Create a Yes/No Column
Follow these steps to create a Yes/No column in SharePoint Online using PnP PowerShell:
Step 1: Connect to SharePoint Online
Open PowerShell and connect to your SharePoint Online site using the following command:
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive
Step 2: Create a Yes/No Site Column
To create a Yes/No column, use the Add-PnPField cmdlet. Here’s an example of creating a Yes/No column named “IsApproved” with specific settings:
Add-PnPField -DisplayName "IsApproved" -InternalName "IsApproved" -Group "Custom Columns" -Required
- DisplayName represents the name displayed in the SharePoint UI.
- InternalName: A unique identifier for the column.
- Group: Specify the column group to organize it logically.
- Required: add the parameter if the column is mandatory.
Step 3: Verify Column Creation
After running the command, verify that the column has been created successfully. You can check the SharePoint site or use the following command:
# This command retrieves information about the newly created column.
Get-PnPField -Identity "IsApproved" | Select DisplayName, InternalName, Type
Conclusion
Creating a Yes/No Site Column using PnP PowerShell in SharePoint Online is a quick and efficient way to customize your lists. With this column in place, you can enhance the data capture and improve the overall usability of your SharePoint site.
Experiment with different parameters and options to tailor the column to your specific requirements. As you continue to explore PnP PowerShell, you’ll discover its potential for automating various SharePoint tasks and making your collaboration experience even more powerful.