Restoring Deleted All Systems Collection

Sometimes things just happen, sometimes you accidentally delete the All Systems collection because you were trying to do too many things at once.  I’ll fess up, I did it.  Here’s how to restore the collection with the appropriate ID.  This solution was given to me by Microsoft Support. Here is the VBS script that will do the restore: ####begin script strSMSServer = “.”
strParentCollID = “COLLROOT”
‘This example creates the collection in the collection root.
‘Replace COLLROOT with the CollectionID of an existing collection to make the new collection a child. strCollectionName = “All Systems”
strCollectionComment = “This is the All Systems Collection.”
Set objLoc = CreateObject(“WbemScripting.SWbemLocator”)
Set objSMS = objloc.ConnectServer(strSMSServer, “rootsms”)
Set Results = objSMS.ExecQuery (“SELECT * From SMS_ProviderLocation WHERE ProviderForLocalSite = true”) For each Loc in Results
If Loc.ProviderForLocalSite = True Then
  Set objSMS = objLoc.ConnectServer(Loc.Machine, “rootsmssite_” & Loc.SiteCode)
End if
Next Set newCollection = objSMS.Get(“SMS_Collection”).SpawnInstance_() ‘Create new “All Systems” collection
newCollection.Name = “All Systems”
newCollection.OwnedByThisSite = True
newCollection.Comment = strCollectionComment
newCollection.CollectionID = “SMS00001”
path = newCollection.Put_ ‘Set the Relationship
Set newCollectionRelation = objSMS.Get(“SMS_CollectToSubCollect”).SpawnInstance_()
newCollectionRelation.parentCollectionID = strParentCollID
newCollectionRelation.subCollectionID = (“SMS00001”)
newCollectionRelation.Put_ ####end script Once you’ve recreated the collection with the appropriate ID, then you’ll have to import the All Systems query for your membership rules.

Leave a Comment