With some help from Chris Nackers blog I found this vb script which restored the collection with the appropriate collection ID -
'###Begin Code
strSMSServer = "ENTER SERVERNAME HERE"
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 Code
Then all I had to do was add my customized query, that removes discovered apple devices, into the collection and do an update/refresh and presto (You could remove the "where" part of the statement to get it back to original) -
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Name not like "%AD" and SMS_R_System.Name not like "%AL"
No comments:
Post a Comment