public static List <FIMSyncManagementAgentRunProfiles> StartMARunProfile(ConnectionCredentials connCreds, string fimMAName, String fimProfileName)
        {
            ManagementClass managementClass = createFIMWMIConnection(connCreds.UserName, connCreds.Password, connCreds.Domain, connCreds.FIMServer);

            List <FIMSyncManagementAgentRunProfiles> managementAgents = new List <FIMSyncManagementAgentRunProfiles>();

            using (ManagementObjectCollection services = managementClass.GetInstances())
            {
                foreach (ManagementObject service in services)
                {
                    if (service["Name"].ToString().ToLower().CompareTo(fimMAName.ToLower()) == 0)
                    {
                        // We just matched the name of the Agent, so its now in context for us to start processing
                        FIMSyncManagementAgentRunProfiles newAgent = new FIMSyncManagementAgentRunProfiles();
                        newAgent.Status = "Located the Management Agent";

                        ManagementBaseObject inParams = service.GetMethodParameters("Execute");
                        inParams["RunProfileName"] = fimProfileName;
                        try
                        {
                            ManagementBaseObject outParams = service.InvokeMethod("Execute", inParams, null);
                            newAgent.Status = outParams["ReturnValue"].ToString();


                            if (newAgent.Status.Contains("success"))
                            {
                                outParams             = service.InvokeMethod("RunStartTime", null, null);
                                newAgent.RunStartTime = outParams["ReturnValue"].ToString();

                                outParams           = service.InvokeMethod("RunEndTime", null, null);
                                newAgent.RunEndTime = outParams["ReturnValue"].ToString();

                                outParams             = service.InvokeMethod("NumCSObjects", null, null);
                                newAgent.NumCSObjects = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumTotalConnectors", null, null);
                                newAgent.NumTotalConnectors = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumConnectors", null, null);
                                newAgent.NumConnectors = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumExplicitConnectors", null, null);
                                newAgent.NumExplicitConnectors = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumTotalDisconnectors", null, null);
                                newAgent.NumTotalDisconnectors = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumDisconnectors", null, null);
                                newAgent.NumDisconnectors = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumExplicitDisconnectors", null, null);
                                newAgent.NumExplicitDisconnectors = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumFilteredDisconnectors", null, null);
                                newAgent.NumFilteredDisconnectors = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumPlaceholders", null, null);
                                newAgent.NumPlaceholders = outParams["ReturnValue"].ToString();

                                outParams             = service.InvokeMethod("NumImportAdd", null, null);
                                newAgent.NumImportAdd = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumImportUpdates", null, null);
                                newAgent.NumImportUpdate = outParams["ReturnValue"].ToString();

                                //outParams = service.InvokeMethod("NumImportDelete", null, null);
                                //newAgent.NumImportDelete = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumImportNoChange", null, null);
                                newAgent.NumImportNoChange = outParams["ReturnValue"].ToString();

                                outParams             = service.InvokeMethod("NumExportAdd", null, null);
                                newAgent.NumExportAdd = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumExportUpdate", null, null);
                                newAgent.NumExportUpdate = outParams["ReturnValue"].ToString();

                                outParams = service.InvokeMethod("NumExportDelete", null, null);
                                newAgent.NumExportDelete = outParams["ReturnValue"].ToString();
                            }

                            managementAgents.Add(newAgent);
                        }

                        catch (Exception ex)
                        {
                            //throw ex;
                            newAgent.Status = ex.ToString();
                        }
                    }
                }
            }

            return(managementAgents);
        }