c# sms 2003 add to collection

G

Guest

In the process of developing a C# GUI for our desktop support team. Basic
code following allows me to query the contents of a collection. Would
someone help me by posting a sample of how to add workstations to a
collection. Thanks

---------------------------------------------------------------------
const string sSMSCollectionProject2003 = "00100037";
const string sSMSCollectionVisio2003 = "00100038";

// Connect to WMI with the Systems.Management .NET Object
// Objects below belong to the Systems.Management Namespace

//Establish Connection Options
ConnectionOptions oConnectionOptions = new ConnectionOptions();
oConnectionOptions.Username = "LEDCOR\\svc_sms";
oConnectionOptions.Password = "master54*";
oConnectionOptions.Authentication = AuthenticationLevel.Default;
oConnectionOptions.Impersonation = ImpersonationLevel.Impersonate;

// Instantiate Management Object Scope on Remote System, and
Remote WMI Path for SMS via the Connection Options
ManagementScope oManScope = new
ManagementScope("\\\\701-1235\\root\\sms\\site_001", oConnectionOptions);

//Query String and Creating a Query Object from that String
string sWQL = "SELECT * FROM SMS_CM_RES_COLL_" +
sSMSCollectionVisio2003;
ObjectQuery oManObjectQuery = new ObjectQuery(sWQL);

// SearchObject Searches Remote Management Scope with Query
ManagementObjectSearcher oManSearcher1 = new
ManagementObjectSearcher(oManScope, oManObjectQuery);

// SearchObject is converted to a Collection for interoperatbility
ManagementObjectCollection oManQueryCollection1 =
oManSearcher1.Get();

foreach (ManagementObject oManObj in oManQueryCollection1)
{
int iNumber = 1;
//MessageBox.Show("objects : " + iNumber);
iNumber++;
//MessageBox.Show(oManObj.Properties.ToString());


// Determines The Names of the Columns in a Collection
PropertyDataCollection.PropertyDataEnumerator
propertyEnumerator = oManObj.Properties.GetEnumerator();

while (propertyEnumerator.MoveNext())
{
PropertyData smsCollection =
(PropertyData)propertyEnumerator.Current;
//MessageBox.Show("Property found: " +
smsCollection.Name);
MessageBox.Show("Value of Property: " +
smsCollection.Value);
}
}
--------------------------------------------------------------------
 
C

chanmm

Check with WMI site. Your piece of code does not seem to be logic to add the
part you mentioned in it.

chanmm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top