Managing Document Sets with the OfficeDev PnP PowerShell cmdlets

I just released a couple of new cmdlets to manage document sets in SharePoint. While at the time of writing these cmdlets are not available in the master branch yet, you can still decide to download the dev branch from the GitHub site and compile that one. The cmdlets will be available in the master branch in the August release. The cmdlets work as described below:

There are 4 cmdlets:

Creating a document set

A document set is basically nothing but a ‘rich’ Content Type, e.g a content type with additional properties. To create a Document Set you can use the Add-SPOContentType cmdlet:

Adding a content type to an existing document set

To add a content type to a document set you have to use the Add-SPOContentTypeToDocumentSet cmdlet. The cmdlets takes a few properties, and there are several ways to provide them:

or

or

or

Of course you can also mix the type of parameters.

Setting the Shared Fields or Welcome Page fields on the document set

You can set certain fields to be shared througout the document set or have certain fields available on the document set welcome page. It is important that you first add those fields to a content type that has been added to the document set. Then with the Set-SPODocumentSetField cmdlet you can set those fields as follows:

The cmdlet above will add the “My Field” field to a document set called “My Document Set” and sets it as a Shared Field and it will make the field available on the Welcome Page. Like the other cmdlets, you can mix and match the values of the DocumentSet and Field parameters to suite your requirements, e.g. you can send in a name, an actual field or document set template object that you retrieved with one of the other cmdlets, or you can send in an id of a field or document set content type.

To remove a field from the welcome page, but keep it as a shared field after you entered the cmdlet above:

You may also like...