1

I all,

I really appreaciate what PnP for O365 has enabled us to do so far. I was wondering how I can change the setting on a list column to require or not require a value. In the GUI this option is named "Require that this column contains information".

I was able to retrieve this setting with Get-PnPField -List 'LibraryTitle' | Where-Object {$_.Title -eq "ColumnName"} | Select Required

This evaluates to either true or false. However, I have no idea how to change this value as Set-PnPField does not exist.

How can I achieve this?

Thanks in advance for your help.

2 Answers 2

2

Not sure when it was added, but PnP powershell does have the Set-PnPField command available.

I would suggest that you update to the latest PnP powershell.

You can run the below command to update it to the latest version:

Update-Module SharePointPnPPowerShell*

Or you, can download it from the below link, it will overwrite the current installation.

Download link - PnP PowerShell releases

Once this is done, you can set the value of a field to required as below:

Set-PnPField -List 'LibraryTitle' -Identity 'ColumnName' -Values @{Required=$true}

Reference - Set-PnPField

2
  • hey @colonel_claypoo, did you try the above approach ? did it work for you ? Commented Sep 28, 2017 at 9:54
  • your code worked for me. PNP commands are updated often, so +1 to check often. I see updates as recent as 10 days from me posting this. github.com/SharePoint/PnP-PowerShell Commented Feb 22, 2019 at 17:07
1

If it is first time creation of field, remove the field using remove-PnPField -List "listname" -identity "guid of field" and add-pnpfield with -required parameter.

Add-PnPField [-AddToDefaultView [<SwitchParameter>]]
             [-Required [<SwitchParameter>]] // true
             [-Group <String>]
             [-Web <WebPipeBind>]

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.