Retrieve, Add, Remove Fields from a SharePoint list using PNP PowerShell

In this blog, we are going to retrieve all fields from a list, add, remove a field from a SharePoint list using PnP PowerShell. First, we need to connect to the Site.

  1. First We Need to Connect to the Site. To Perform Connection Add

$SiteUrl = Read-Host “Provide Site url”

Connect-PnPOnline -Url $SiteUrl

#Executing this line will ask for credentials. Provide user name and password to connect.

2. To retrieve all fields add below command

$Fields = Get-PnPField  -List “Test”

3. To add a field to a list

Add-PnPField -List “Test” -DisplayName “Designation” -InternalName “Designation” -Type MultiChoice  -AddToDefaultView -Choices “HR”,”CEO”, “DEVELOPER”,”TESTER”

4. To remove a field from the list

Remove-PnPField -List “Test” -Identity “Designation”

Executing this command open a pop-up window for confirmation of field delete

Clicking on yes will remove the field from list.

Tags: , , , , ,

Leave a Reply

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