Powershell tip for updating document sets

Wed, Jul 20, 2011 2-minute read

If you’re using the handy Document Sets feature in SharePoint 2010 you may run in to a small issue where you make some changes to your document set (e.g., add/remove content types from the allowed contents). When you do this, and push changes down to existing document sets, you’ll see a little yellow bar appear on each document set with the message

“Content Types that are available to this Document Set have been added or removed. Click here to update the Document Set.”

The reason is that the document set refresh date needs updating. Quite why SharePoint can’t manage this for you, is beyond me, but nevertheless, if you do click the yellow bar, it disappears. But it still remains for all your other document sets. Irritating. So here’s how to remove the little yellow bar with the message using Powershell. The neatest way is just to provision the document set.

Powershell script

$weburl = "http://yourURL"
$web = Get-SPWeb $weburl
$lib = $web.Lists["Document Library Name"]
$lib.Items | Where-Object {$_.Folder -ne $null} | ForEach-Object {
 Write-Host "Provisioning " $item.Name
 $ds = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::GetDocumentSet($item.Folder)

And that ought to do it.

Original inspiration from here and here

Post was updated based on Rod’s comments below. Also what is poor in the script is it uses $lib.Items directly which is BAD on a large library. You would typically execute a paged request to process large libraries. If you are running this on a large library then be prepared for memory issues.