SCOM 2012 agent failover configuration is very simple. You have to run just below operation shell.
For example below is the primary & secondary SCOM gateway server where all agents are reporting.
Primary : XYZ01.com
Secondary : XYZ02.com
For example if your primary SCOM gateway (XYZ01.com) is down it all agent should report to Secondary gateway server (XYZ02.com).
$primaryMS = Get-ManagementServer | where {$_.Name –eq ‘ XYZ01.com ‘}
$failoverMS = Get-ManagementServer | where {$_.Name –eq ‘ XYZ02.com ‘}
$agent = Get-Agent | where {$_.PrimaryManagementServerName -eq ‘ XYZ01.com ‘}
Set-ManagementServer -AgentManagedComputer: $agent -PrimaryManagementServer: $primaryMS -FailoverServer: $failoverMS
If your secondary SCOM gateway server (XYZ02.com) is down, all agent which is reporting to secondary gateway server it should report to primary gateway server (XYZ01.com)
$primaryMS = Get-ManagementServer | where {$_.Name –eq ‘ XYZ02.com ‘}
$failoverMS = Get-ManagementServer | where {$_.Name –eq ‘ XYZ01.com ‘}
$agent = Get-Agent | where {$_.PrimaryManagementServerName -eq ‘ XYZ02.com ‘}
Set-ManagementServer -AgentManagedComputer: $agent -PrimaryManagementServer: $primaryMS -FailoverServer: $failoverMS