Thursday, September 27, 2012

SCSM Update Incident Using C#

SCSM Update Incident Using C#

 

static void Main(string[] args)

{

Thread.Sleep(30000);


List<EnterpriseManagementObject> Incidents = GetAllIncidents();

  updateIncident("Escalated", "True"Incidents.ElementAt(0));
 
}static void updateIncident(string param, string value, EnterpriseManagementObject item)

{


EnterpriseManagementGroup emg = new EnterpriseManagementGroup("localhost");



ManagementPackClass mpcWorkitem = emg.EntityTypes.GetClass(new Guid("f59821e2-0364-ed2c-19e3-752efbb1ece9"));



ManagementPack mpIncident = emg.ManagementPacks.GetManagementPack("System.WorkItem.Incident.Library", "31bf3856ad364e35", new Version(1, 0, 0, 0));



//Get the incident class from the MP (System.WorkItem.Incident)



ManagementPackClass mpcIncident = mpIncident.GetClass("System.WorkItem.Incident");

item[mpcIncident, param].Value = value;

item.Commit();

item.Overwrite();

}