1
$fix11 = Add-PnPField `
  -DisplayName 'Date of Birth' `
  -InternalName DateofBirth `
  -Type Date `
  -Required `
  -Group 'Football Content Types'

The Required parameter doesn't seem to work, any one experiencing the same thing?

2

In my test, it working fine. You can go to Site Settings->Site Columns and check this column.

enter image description here

My test script as below.

$URL='https://tenant.sharepoint.com/sites/team'
Connect-PnPOnline –Url $URL –Credentials (Get-Credential)
$fix11 = Add-PnPField `
  -DisplayName 'Date of Birth' `
  -InternalName DateofBirth `
  -Type Date `
  -Required `
  -Group 'Football Content Types'

I run the script in SharePoint Online Management Shell with the latest PnP PowerShell. I suggest you install the latest PnP PowerShell to check if it works.

| improve this answer | |
  • How annoying it works for you but not me ! I need to do it via scripting, might try the xml way to add fields via pnp :) Thank you. – BennKingy Nov 26 '19 at 10:32
1

Worked for me to with just using the -Required parameter. Are you running on the latest version of the PnP-PowerShell module?

Try to use a switch and set it to $true and see if it work's any better. -$Required:$true.

| improve this answer | |
0
$fix18 = Add-PnPFieldToContentType `
  -ContentType 'Player Bio' `
  -Field Club `
  -Required 

The required field needed to be added to Add-PnPFieldToContentType also. That fixed it!

| improve this answer | |

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.