0

I want to create a boolean site column (yes/no field) througn pnp power shell. I used Add-PnPField command, but how to set default value to "no"

2

After you create your field using Add-PnPField, you need to get that field using Get-PnPField and set the default value as below:

$field = Get-PnPField -List CustomList -Identity "BoolField"
$field.DefaultValue = "0"
$field.Update()
Invoke-PnPQuery

Also, you can use PnPFieldFromXml itself to create a boolean field with No as default value as :

$fieldXml = "<Field Type='Boolean' Name='TestBool' StaticName='TestBool' DisplayName='Test Bool'><Default>0</Default></Field>"
Add-PnPFieldFromXml -FieldXml $fieldXml

References - Add-PnPFieldFromXml

Create fields using CSOM

  • hey @gokulnath, hope that helped you. You can accept this answer which will earn you the learner badge as well as remove it from the unanswered questions list ! Cheers, thanks ! – Gautam Sheth Aug 28 '18 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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