How To Restore the ‘All Systems’ Collection

The default All Systems collection is special in the sense that it has a unique Collection ID (SMS00001). In case you end up 'accidentally' deleting the All Systems collection from your SMS/SCCM console, the only way to restore it with the default Collection ID is programmatically. Here's a script that does that, along with adding the Collection Query and the Update Schedule.

strSMSServer = "."
strParentCollID = "COLLROOT"
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
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"
'Set the Relationship
Set newCollectionRelation = objSMS.Get("SMS_CollectToSubCollect").SpawnInstance_()
newCollectionRelation.parentCollectionID = strParentCollID
newCollectionRelation.subCollectionID = ("SMS00001")
'Add the Query Rule
Set objQueryRule = objSMS.Get("SMS_CollectionRuleQuery").SpawnInstance_
objQueryRule.QueryExpression = Query
objQueryRule.RuleName = "All Systems"
newCollection.AddMembershipRule objQueryRule
'Add the Schedule
Set Token = objSMS.Get("SMS_ST_RecurInterval")
Token.DaySpan = 1
newCollection.RefreshSchedule = Array(Token)
newCollection.RefreshType = 2
'Refresh Collection Membership
newCollection.RequestRefresh False

Run the script as follows on the Site Server, and you should have the default collection back:
cscript.exe RecreateAllSystemsCollection.vbs

IMPORTANT: Using the example above works in my lab, however information in this post is provided "AS IS" with NO Warranties, or Support.

Vinay Pamnani | Support Engineer

Comments (1)

Skip to main content