Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
$siteURL="http://intra.colgate.com/sites/vendors"
$docLib = "SOA"
$site=Get-SPSite $siteURL
$web=$site.RootWeb
$collFiles=$web.GetFolder($docLib).Files
$count=$collFiles.Count
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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.