Structure Document IDs to be unique across Site Collections Structure Document IDs to be unique across Site Collections
Arpit Patel

Arpit Patel

September 04, 2012

All Post
Structure-Document-IDs-to-be-unique-across-Site-Collections
Share:

Configure Document IDs to be unique across the farm

Document IDs are only guaranteed unique within a single site collection. SharePoint tries to ensure uniqueness by putting a random prefix in front of each Docuemnt ID, and setting that at the Site Collection level. However you can easily rationalize these, and make the Document IDs a bit easier to read. The script below assigns a prefix, and sets up SharePoint to reissue Document IDs. Note the actual regeneration of Document IDs will wait until the Document ID Assignment Timer Job runs. This job can take a long time to run, depending on the number of items in your Site Collections.

 

 [system.reflection.assembly]::LoadWithPartialName("Microsoft.Office.DocumentManagement") 
$siteUrl = "http ://SharePoint/ManagedPath"  #this is the header prefixing my Site Collections
 
$LoopString = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"  #Here are the individual Site Collections
$LoopStringArr = $LoopString.Split(,)
 
foreach ($letter in $LoopStringArr)
{
    $SiteName=$siteurl+$letter
    write-host $SiteName
 
    $Site = New-Object Microsoft.SharePoint.SPSite($SiteName)
    [Microsoft.Office.DocumentManagement.DocumentID]::EnableAssignment($Site,$false)   #First disable, then enable DocID assignment
    [Microsoft.Office.DocumentManagement.DocumentID]::EnableAssignment($Site,$true)
 
 
    $rootweb=$site.rootweb
    $rootweb.properties["docid_msft_hier_siteprefix"]="Ins$letter"  # This is the property holding the Document ID Prefix which we use to ensure uniqueness
    $rootweb.properties.Update()
    $rootweb.Update()
    [Microsoft.Office.DocumentManagement.DocumentID]::EnableAssignment($Site,$true,$true,$true)  # now we can force all Document IDs to be reissued
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to talk?

Drop us a line. We are here to answer your questions 24*7.