Deleting all the clients under a collection using script

Is there a way to delete all the clients under a collection using a script or on a schedule? Like for example, if I have a query based  collection that contains all the linux machines, and I want to delete these linux machines from the SCCM database.

Thanks.

July 2nd, 2013 12:37am

Yes you can do that, every thing that you need is within the CM07 SDK.
Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2013 5:46am

Thanks, Garth. I tried it and it worked. Here is the my script if anyone is interested.

ON ERROR RESUME NEXT

strServer= "."
strSiteCode="ABC"
strCollection = "ABC000FC"
Set locator = CreateObject( "WbemScripting.SWbemLocator" )
Set WbemServices1 = locator.ConnectServer( strServer,"root\SMS\site_" & strSiteCode )

strQryName = "Select ResourceID from SMS_FullCollectionMembership where CollectionID=" & "'" & strCollection & "'"

Set ListOfResources1 = WbemServices1.ExecQuery(strQryName)

For Each Resource1 in ListOfResources1
FOr Each oProp in Resource1.Properties_
GetResID = oProp.Value
Msgbox("The ResourceID is " & GetResID)
Set sResource = WbemServices1.Get("SMS_R_System='" & GetResID & "'")
sResource.Delete_
Next
Next



July 3rd, 2013 5:11pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics