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

I am sure something wrong with the following code. There are over 400 document-sets in the library and script only shows 8. Please suggest which line is messed up. (At one time I could get this work)

$webUrl = "http://theportal.company.sales/sites/sales"
$web = Get-SPWeb $webUrl
$list = $web.Lists["SalesScripts"]

foreach ($item in $list.Items  | Where-Object {$_.Folder -ne $null}) 
{
    try
    {   $field = $item["Title"]
Write-Host “Provisioning ” $item.Name
$ds = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::GetDocumentSet($item.Folder)
$ds.Provision()
    }
    catch
    {
       write-host "something went wrong"
    }
}
$web.dispose()
share|improve this question
    
Hey what happened. I thought I would get some hint from you all (the SP gurus)... –  Rosie O'Donnell Nov 10 '11 at 13:51
2  
I totally understand your frustration. Don't expect high quality answer or quick turn around from this site. I face the same dilemma every time I post a question. I usually Google but I know sometimes that does not help. I would help but new to Doc Set. May want to revisit the content types associated with Doc Set. or may want to iterate another way so you get all the doc set that content type="Document Set" (or what ever the name of the doc set content type in your environment) –  Mary Rivers Nov 10 '11 at 14:30

1 Answer 1

You can simply that code a bit

$site = Get-SPSite "http://somesite"
$web = Get-SPWeb "http://somesite" #gets the root web of somesite
$subweb = Get-SPWeb "http://somesite/someweb" 

foreach($docsetFolder in $rootFolder.SubFolders | where { $_.Name -ne "Forms"})
{
        foreach ($doc in $docsetFolder.Files)
        {
                    $doc | Select Name, ContentTypeId | Sort Name
        }
}

Here is another method in C# so you have convert it to PS

public static bool IsDocumentSet(this SPListItem item)
{
 bool documentSetItem = false;
 DocumentSet documentSet = null;

 if (null != item && item.IsFolder())
 {
  documentSet = DocumentSet.GetDocumentSet(item.Folder);

  if (null != documentSet)
   documentSetItem = true;
 }
 return documentSetItem;
}
share|improve this answer

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.