How to Approve Manual Agent Installations

System Center

Updated: May 22, 2009

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007

If you do not need to fully automate the deployment of agents but you still want to automate the approval of manually deployed agents, you can query the pending actions that require approval, and then approve them by using the Operations Manager class libraries.


The following example demonstrates how to approve a pending action that adds a computer with a manually installed agent to the Management Group. Other types of pending actions can be approved in a similar manner.

/// <summary>
/// Allows all computers with a manually installed agent 
/// to join the Management Group.
/// </summary>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
using Microsoft.EnterpriseManagement.Common;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;
using System.Text;

namespace SDKSamples
    class Program
        static void Main(string[] args)
            Console.WriteLine("Approving manual agent installations.");

            ManagementGroup mg = new ManagementGroup("localhost");
            ManagementGroupAdministration mga = mg.GetAdministration();

            ReadOnlyCollection<AgentPendingAction> pendingActions = mga.GetAgentPendingActions();
            if (pendingActions.Count == 0)
                Console.WriteLine("There are no pending actions for this Management Group.");

            List<AgentPendingAction> approvedActions = new List<AgentPendingAction>();
            foreach (AgentPendingAction action in pendingActions)
                // Approve pending actions only for manually installed agents.
                if (action.AgentPendingActionType == AgentPendingActionType.ManualApproval)
                    Console.WriteLine("Agent " + action.AgentName + " waiting for approval...");
                    Console.WriteLine(action.AgentName + " has been approved.");

            catch (UnknownServiceException e)
                Console.WriteLine("No agents were approved (possibly because no agents were waiting for approval).");

See Also