Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

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.

Example

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.

' Allows all computers with a manually installed agent 
' to join the Management Group.
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Administration
Imports Microsoft.EnterpriseManagement.Common
Imports Microsoft.EnterpriseManagement.Configuration
Imports Microsoft.EnterpriseManagement.Monitoring
Imports System.Text

Namespace SDKSamples
    Class Program
        Public Overloads Shared Function Main(ByVal args() As String) As Integer
            Console.WriteLine("Approving manual agent installations.")

            Dim mg As ManagementGroup = New ManagementGroup("localhost")
            Dim mga As ManagementGroupAdministration = mg.GetAdministration()

            Dim pendingActions As ReadOnlyCollection(Of AgentPendingAction) = mga.GetAgentPendingActions()
            If pendingActions.Count = 0 Then
                Console.WriteLine("There are no pending actions for this Management Group.")
                Return 1
            End If

            Dim approvedActions As List(Of AgentPendingAction) = New List(Of AgentPendingAction)()
            Dim action As AgentPendingAction
            For Each action In pendingActions
                ' Approve pending actions only for manually installed agents.
                If action.AgentPendingActionType = AgentPendingActionType.ManualApproval Then
                    Console.WriteLine("Agent " & action.AgentName & " waiting for approval...")

                    approvedActions.Add(action)
                    Console.WriteLine(action.AgentName & " has been approved.")

                End If
            Next

            Try
                mga.ApproveAgentPendingActions(approvedActions)
            Catch e As UnknownServiceException
                Console.WriteLine("No agents were approved (possibly because no agents were waiting for approval).")
            End Try
        End Function
    End Class
End Namespace

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.