SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Adding If doc set does not exist then create doc set. What would be the syntax for looking up document set then create (if does not exists)

### Create new Document Set
$docLib = "SOA"
$site=Get-SPSite $siteURL
while($count -ne 0)
$item = $collFiles[$count-1].Item
    $DocSetName = $item["Vendor"]
    $newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($list.RootFolder,"Document Set Title",$cType.Id,$docsetProperties)
share|improve this question
Did you guys change the site look n feel? Is it still a php site? – Mala Singha Sep 13 '11 at 21:34
our beta design is gone as of tonight as we soon will be moving out of beta. Please keep this kind of comments on meta :-) – Anders Rask Sep 13 '11 at 21:42
up vote 3 down vote accepted

I'm not sure if I'm answering the right question, but I used this method to check if Doc Set (folder) exists, and if not, create:

[Microsoft.SharePoint.SPFolder]$targetFolder = $rootWeb.GetFolder($targetDocLib.RootFolder.ServerRelativeUrl + "/$docSetName")

if (-not $targetFolder.Exists)
    # create

This approach worked for me.

share|improve this answer
Thanks for posting the code. I will try it tomorrow. Thanks again – Mala Singha Sep 13 '11 at 23:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.