SharePoint PowerShell How To: Create SharePoint Document Sets for Load/Performance Testing

SharePoint PowerShell How To Series – Foreword

I often find myself scratching around the local drive of my development machines for remnants of PowerShell scripts to generate list & libraries in SharePoint with all sorts of different folder hierarchies to test the performance of code I’m working on to ensure it scales well once the folder & item counts start getting up to high numbers. So rather than keep scratching I’m going to start posting my scripts as I create and use them so I can find/reuse them later on and someone else might find them useful as well. I’m sure they won’t work under all scenarios and situations (and they are not designed to). They are just quick scripts that serve a specific purpose to me at the time and you may be able to tweak to fit your needs.

Create document sets in the root of a document library

Script description: Create 6000 document sets within the “Document Set Performance Test” library of the “LocationContentTesting” site on the SharePoint Server “vs-server82”.

Note: this assumes you have made have the standard “Document Set” content type available in the library.

#Script settings
$webUrl = "http://vs-server82/locationcontenttesting"
$listName = "Document Set Performance Test"
$numberDocSetsToCreate = 6000
$docSetNamePrefix = "Doc Set Load Test "

### Get web and list
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

### Get Document Set Content Type from list
$cType = $list.ContentTypes["Document Set"]

### Create new Document Set
[Hashtable]$docsetProperties = @{}

# Create desired number of subfolders
for($i=1; $i -le $numberDocSetsToCreate; $i++)
    $newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($list.RootFolder,"$docSetNamePrefix$i",$cType.Id, $docsetProperties)
    write-host "$docSetNamePrefix$i ... created"


Related articles

About Cameron Dwyer

Chief Technology Officer at OnePlace Solutions. Microsoft MVP: Office Dev Passionate about delivering compelling solutions on the Office 365/SharePoint platform. Addicted to coffee.

Posted on December 10, 2013, in PowerShell, SharePoint and tagged , , , , , , , , , , , . Bookmark the permalink. 8 Comments.

  1. Hi,I get a error message,Cannot find an overload for “Create” and the argument count: “4”,is somewhere i write wrong?


  2. Hi
    Fiirst of all many thanks for the script & for your contribution,

    I would like to get a hint on how to upload folders (with subfolders containing sub files) to a document set from a location on the c drive.

    Thanks in advance for your help,



  3. Hi Cameron,
    Excellent article. I have a bit different requirement. I already have a document set where there are existing documents. Now I would like to set a choice field of these existing documents to a specific value. Is it possible using Powershell?


  1. Pingback: Les dossiers et le seuil d’affichage | KTNN SharePoint

  2. Pingback: Les ensembles de documents et le seuil d’affichage | KTNN SharePoint

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: