Expand and document functionality for Add-PnPField and Add-PnPTaxonomyField

Brass Contributor

There is zero documentation and examples for -FieldOptions for both Add-PnPField and Add-PnPTaxonomyField.

 

I'm trying to use both cmdlets above to add Site Columns to my webs, right now I can't set the "Maximum Characters" when creating a Text field (not available for Add-PnPField), and it is not even possible using something like this:

 

$x = Add-PnPField -DisplayName "Test" -InternalName Test -Type Text
$x.Length = 50   // there is no such property for Site Columns
$x.Update()

How do I set the max characters now?

 

And I'm also trying to use Set-PnPField to accomplish the same will fail, there is no MaxLength, Length, or even Maximum, I can't find any way to set up the maximum number of characters for a site column.

 

The other problem I have, while trying to use Add-PnPTaxonomyField, I would like to use -FieldOptions to set up the defaultValue of the new site column, and also use its other Field Options, but I can't find any examples on the internet.

 

Would be extremely good to have a parameter "-DEFAULTVALUE" for both cmdlets to define the default value for new site columns, and also "-MAXLENGHT", both cmdlets are very useful seems to be barely complete in their current state.

1 Reply

Going through a similar exercise myself, I'm finding that Add-PnPFieldFromXML provides much more control over the field properties. The downside is that it requires you to generate the XML file, which is nearly as tedious as using the GUI. Still, it's possible. See https://msdn.microsoft.com/en-us/library/office/ms437580(v=office.15).aspx for a list of field properties that can be included in the XML.