I am creating a Document Set for a library using powershell and that document set contains some mandatory managed metadata fields. I am able to create document set but how can I insert data into those managed metadata fields at runtime?
You have to connect to the term store and then construct a TaxonomyFieldValue and then use the target field's SetFieldValue() method to assign the value.
Hope this helps someone.
You have to get a reference to the Managed metadata item from term store as shown below
Create the document set as shown below
Get a reference to the inserted document set
Get a reference to the taxonomy field from the inserted document set
Call the Update method on the item
This will update the Managed metadata field in the Document Set.