Problem after import a single computer on a specific collection. Due to delete.


  • I add a new computer on a collectrion for OS deployment.  All it's OK but if i delete the machine on the collection(click on the collection, select the computer and press delete, there enough a trace of the computer on membershiprule.


    It's due to my creation?

    i use the code found on the SDK.


    public int AddNewComputer(WqlConnectionManager connection, string netBiosName, string smBiosGuid, string macAddress, string colID)  
                    if (smBiosGuid == null && macAddress == null)  
                        throw new ArgumentNullException("smBiosGuid or macAddress must be defined");  
                    // Reformat macAddress to : separator.  
                    if (string.IsNullOrEmpty(macAddress) == false)  
                        macAddress = macAddress.Replace("-"":");  
                    // Create the computer.  
                    Dictionary<stringobject> inParams = new Dictionary<stringobject>();  
                    inParams.Add("NetbiosName", netBiosName);  
                    inParams.Add("SMBIOSGUID", smBiosGuid);  
                    inParams.Add("MACAddress", macAddress);  
                    IResultObject outParams = connection.ExecuteMethod("SMS_Site""ImportMachineEntry", inParams);  
                    // Add to All System collection.  
                    IResultObject collection = connection.GetInstance("SMS_Collection.collectionId='" + colID + "'");  
                    //IResultObject collection = connection.GetInstance("SMS_Collection.collectionId='SMS00001'");  
                    IResultObject collectionRule = connection.CreateEmbeddedObjectInstance("SMS_CollectionRuleDirect");  
                    collectionRule["ResourceClassName"].StringValue = "SMS_R_System";  
                    collectionRule["ResourceID"].IntegerValue = outParams["ResourceID"].IntegerValue;  
                    Dictionary<stringobject> inParams2 = new Dictionary<stringobject>();  
                    inParams2.Add("collectionRule", collectionRule);  
                    collection.ExecuteMethod("AddMembershipRule", inParams2);  
                    return outParams["ResourceID"].IntegerValue;  
                catch (SmsException e)  
                    richTextBox1.Text += "\nFailed to add the computer " + netBiosName + " Error: " + e.Message;  
                return 0;  



    28 Januari 2009 14:46

Semua Balasan

  • It's not terribly clear what you're asking but if you delete a computer directly from a collection (as opposed to going into the collection properties and deleting it) then you will delete the computer from the SCCM DB and that resource will no longer exist (and therefore will not be able to add it to any other collection).
    09 Mei 2012 22:15