When I got into the office this morning an email came in from one of our technicians. The issue was that he couldn't see the All Systems collection anymore and wanted me to put it back. Since I know I didn't do this, I took a look at Status Message Queries to see what happened. I specifically looked at "Collections Created, Modified, or Deleted" to see who the culprit was and when the deletion happened. Once I figured out that yes, All Systems was in fact deleted, I ran the following VBScript (copy this text to a text file and save it as all_systems.vbs and run it on your site server):
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
NextSet 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_'Add the Query Rule
Query = "SELECT * FROM SMS_R_SYSTEM"
Set objQueryRule = objSMS.Get("SMS_CollectionRuleQuery").SpawnInstance_
objQueryRule.QueryExpression = Query
objQueryRule.RuleName = "AllSystems"
newCollection.AddMembershipRule objQueryRule
The collection was remade and all the objects are there like they should be. Now I need to lock all collections down so our techs don't delete them anymore.
3 Responses
Fixed an issue with this script and smart quotes. This was causing issues when running the script.
Thx for this Script
[...] Source:https://richardbalsley.com/sccm-how-to-restore-the-all-systems-collection-in-sccmsms Like this:GillaBli först att gilla denna post. Kommentera [...]