Saturday, November 17, 2012

SCOM 2012 - Configure Agent Failover to Multiple Gateway Servers

When you have gateway servers configured in your enterprise they agents they manage are configured, by default to contact the primary gateway server. The one assigned and configured at the time of deployment. Now if there is more than one gateway server in this untrusted domain, this is not the optimal configuration. You want to make sure that in the event of one gateway server going down all agents will look to the other server. There are a couple ways of doing this.

Both ways require the use of the  Operations Manager Shell. To configure the agents, open Operations Manager Shell.
Start > All Programs > Microsoft System Center 2012 > Operations Manager Shell

Configuring Servers One at a Time:
If you only need to configure one, or a small number of servers you can run the following command for each and it shouldn't take too much time.
$primaryMS = Get-SCOMManagementServer –Name “<name of primary server>”
$failoverMS = Get-SCOMManagementServer –Name “<name of 1st failover>”,”<name of 2nd failover>”,”<name of nth failover>”
$agent = Get-SCOMAgent –Name “<name of agent>”

Set-SCOMParentManagementServer –Agent $agent –PrimaryServer $primaryMS
Set-SCOMParentManagementServer –Agent $agent –FailoverServer $failoverMS 
You will return to a command prompt if successful.

Configuring Servers in a Group:
If you have just setup your gateway servers and deployed a lot of agents using the one at a time method is tedious and time consuming. The following script will pull the agents and gateway servers from a spreadsheet and process all of them automatically. Enter the agents and gateway servers as shown below and save the file as c:\servers.txt

Now that we have our server list lets go ahead and bring Operations Manager Shell back up and run the following command.
#Pass in comma-separated list 
$List = Import-Csv C:\servers.txt

#Loop through each line of the csv file  
ForEach ($entry in $list){ 
$AgentName = $($entry.Agent)
$PrimaryMSName = $($entry.PrimaryMS)
$FailoverMSName = $($entry.FailoverMS) 

#Set Primary Management Server on Agent
Set-SCOMParentManagementServer -Agent (Get-SCOMAgent -DNSHostName "$AgentName") `
-PrimaryServer (Get-SCOMManagementServer -Name "$PrimaryMSName")  -PassThru

#Set Fail-over Management Server on Agent
Set-SCOMParentManagementServer -Agent (Get-SCOMAgent -DNSHostName "$AgentName") `
-FailoverServer (Get-SCOMManagementServer -Name "$FailoverMSName") -PassThru
} 
It should be fairly easy to see what is happening at each step and is the fastest and simplest way to implement failover to agents.


More to come!


Contributing documentation:
Microsoft Technet
Peter Zerger

2 comments:

  1. where we have to set the Primary and failover management server names in the above script?

    ReplyDelete
    Replies
    1. You would set those in the .txt file. The script will query this for the server information.

      Delete