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

%3CLINGO-SUB%20id%3D%22lingo-sub-122378%22%20slang%3D%22en-US%22%3EExpand%20and%20document%20functionality%20for%20Add-PnPField%20and%20Add-PnPTaxonomyField%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-122378%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20is%20zero%20documentation%20and%20examples%20for%20%3CSTRONG%3E-FieldOptions%3C%2FSTRONG%3Efor%20both%20%3CSTRONG%3EAdd-PnPField%3C%2FSTRONG%3Eand%26nbsp%3B%3CSTRONG%3EAdd-PnPTaxonomyField.%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20use%20both%20cmdlets%20above%20to%20add%20Site%20Columns%20to%20my%20webs%2C%20right%20now%20I%20can't%20set%20the%20%22Maximum%20Characters%22%20when%20creating%20a%20Text%20field%20(not%20available%20for%20Add-PnPField)%2C%20and%20it%20is%20not%20even%20possible%20using%20something%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24x%20%3D%20Add-PnPField%20-DisplayName%20%22Test%22%20-InternalName%26nbsp%3BTest%26nbsp%3B-Type%20Text%0A%24x.Length%20%3D%2050%20%20%20%2F%2F%20there%20is%20no%20such%20property%20for%20Site%20Columns%0A%24x.Update()%3C%2FPRE%3E%3CP%3EHow%20do%20I%20set%20the%20max%20characters%20now%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20I'm%20also%20trying%20to%20use%20Set-PnPField%20to%20accomplish%20the%20same%20will%20fail%2C%20there%20is%20no%20MaxLength%2C%20Length%2C%20or%20even%20Maximum%2C%20I%20can't%20find%20any%20way%20to%20set%20up%20the%20maximum%20number%20of%20characters%20for%20a%20site%20column.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20other%20problem%20I%20have%2C%20while%20trying%20to%20use%26nbsp%3B%3CSTRONG%3EAdd-PnPTaxonomyField%3C%2FSTRONG%3E%2C%20I%20would%20like%20to%20use%26nbsp%3B%3CSTRONG%3E-FieldOptions%3C%2FSTRONG%3E%26nbsp%3Bto%20set%20up%20the%26nbsp%3B%3CSTRONG%3EdefaultValue%3C%2FSTRONG%3Eof%20the%20new%20site%20column%2C%20and%20also%20use%20its%20other%20Field%20Options%2C%20but%20I%20can't%20find%20any%20examples%20on%20the%20internet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWould%20be%20extremely%20good%20to%20have%20a%20parameter%20%3CSTRONG%3E%22-DEFAULTVALUE%22%3C%2FSTRONG%3E%26nbsp%3Bfor%20both%20cmdlets%20to%20define%20the%20default%20value%20for%20new%20site%20columns%2C%20and%20also%20%3CSTRONG%3E%22-MAXLENGHT%22%3C%2FSTRONG%3E%2C%20both%20cmdlets%20are%20very%20useful%26nbsp%3Bseems%20to%20be%20barely%20complete%20in%20their%20current%20state.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-161906%22%20slang%3D%22en-US%22%3ERe%3A%20Expand%20and%20document%20functionality%20for%20Add-PnPField%20and%20Add-PnPTaxonomyField%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-161906%22%20slang%3D%22en-US%22%3E%3CP%3EGoing%20through%20a%20similar%20exercise%20myself%2C%20I'm%20finding%20that%20Add-PnPFieldFromXML%20provides%26nbsp%3B%3CEM%3E%3CSTRONG%3Emuch%3C%2FSTRONG%3E%3C%2FEM%3Emore%20control%20over%20the%20field%20properties.%20The%20downside%20is%20that%20it%20requires%20you%20to%20generate%20the%20XML%20file%2C%20which%20is%20nearly%20as%20tedious%20as%20using%20the%20GUI.%20Still%2C%20it's%20possible.%20See%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fms437580(v%3Doffice.15).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fms437580(v%3Doffice.15).aspx%3C%2FA%3Efor%20a%20list%20of%20field%20properties%20that%20can%20be%20included%20in%20the%20XML.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New 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.