Blog Archives

Restoring All Systems Collection in SCCM 2007


بسم الله الرحمن الرحيم

Sometimes we accidentally deleted important things.I deleted the All System Collection from SCCM 2007 console. I search for restoring the All System Collection with the appropriate ID SMS00001. I found many solutions but this solution is the best one.

Here’s how to restore the All System Collection with the appropriate ID SMS00001

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, “root\sms”)   
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, “root\sms\site_” & 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

How to make this script?

1- Create New Text Document on your Desktop and copy script on New Text Document and save it.

2- Rename New Text Document.txt to RestoringAllSystemsCollection.vbs (.TXT to .VBS)

3- Run the command  C:\Users\administrator\Desktop>cscript.exe “RestoringAllSystemsCollection.vbs”

You will found the All System Collection with the appropriate ID under Collections node in SCCM console. But you will need to import the All Systems query for your membership rules.

Follow these steps to import the All Systems query : 

                            

       

There is an easy way. Re-apply SP2 (or SP1) and the collection will get re-create with the right ID SMS00001

Reference:

http://myitforum.com/cs2/blogs/cnackers/archive/2010/03/17/restoring-deleted-all-systems-collection.aspx