How to change a property retrieved by Get-PnPField if there's no Set-PnPField?
-
01-01-2021 - |
سؤال
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.
المحلول
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
نصائح أخرى
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>]