2

I have a list in SharePoint with 50 content types. My list has two columns that I want to add to each content type in my list using PNP library. Until now I have something like this:

Add-PnPField -List $listTitle -Field $_.Name 

But I could't find a way to check that "Add to all content types" checkbox from PNP. I've tried

-AddToAllContentTypes 

but i've got this error: Add-PnPField : A positional parameter cannot be found that accepts argument 'AddFieldOptions.AddToNoContentType'.

Any way to do that ?

1 Answer 1

2

Try adding -FieldOptions AddToAllContentTypes parameter to your Add-PnPField command.

For Example:

Add-PnPField -List "New list" -DisplayName "New List Column" -InternalName "NewListColumn" -Type Text -Required -AddToDefaultView -FieldOptions AddToAllContentTypes

Source: Add-PnPField: Create List Column in SharePoint using PowerShell

Note:

  1. As per the March 2020 Release, They have removed FieldOptions argument from Add-PnPField.

  2. So, you might try using above command by installing January 2020 Release (v3.17.2001.0) or February 2020 Release(v3.18.2002.0).

How to change versions of PnP PowerShell

3
  • Try suggestions mentioned in my updated answer. I have never tried it but found this useful information on internet. this might help you. May 29, 2020 at 8:59
  • 1
    Hello, indeed this can be a solution but since the project is for a client, i cannot change the version of pnp to an older one. I have tried your solution to the latest pnp version and it's not accepted : WARNING: Parameter 'FieldOptions' is obsolete. Not in use
    – Ana Pop
    May 29, 2020 at 10:00
  • Yes, because they have removed FieldOptions parameter from all releases after February 2020 Release. May 29, 2020 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.