C# SCCM 2012 Administration Tool

Lianamelissa posted 3 months ago in General

Hi all, Im trying to program a simple administration tool for using with SCCM 2012. For our supporters, so they dont have to use Configuration Manager just for adding and removing applications from PCs.

I have made a little application so far, that list all the Add-On Collections in a ComboBox (e.g. adobe and so on) using query from SMS_Collection.

But i cannot figure out how i can add this collection to a computername/resource id?

Can anyone tell me a way? i studied SDK 2012 for SCCM but i still cant figure out how its done.

My code so far, but with a lot of commected out lines different things i tried.

public partial class Form1 : Form { public Form1() { InitializeComponent(); ////connect to sccm this.sccmConnection.Connect("sccmserver");

////get a list of the avialable collections
    string collectionQuery = "SELECT * FROM SMS_Collection Where Name = '{0}'";
    WqlQueryResultsObject collections = this.sccmConnection.QueryProcessor.ExecuteQuery(collectionQuery) as WqlQueryResultsObject;
    foreach (WqlResultObject collection in collections)
    {
        this.cmbCollection.Items.Add(collection.PropertyList["Name"]);
    }
    if (this.cmbCollection.Items.Count > 0)
    {
        this.cmbCollection.SelectedIndex = 0;
    }
}

private WqlConnectionManager sccmConnection = new WqlConnectionManager();


private void btnDeploy_Click(object sender, EventArgs e)
{

    foreach (IResultObject oSystem in this.sccmConnection.QueryProcessor.ExecuteQuery("Select ResourceID From SMS_R_System Where NetBIOSName = 'PC1'"))
    {
        MessageBox.Show(oSystem["ResourceID"].IntegerValue.ToString());
    }
}

Please login to leave a reply, or register at first.