Powershell Commands to configure Gateway Server / Agent Failover

Published 03-12-2019 04:52 PM 345 Views
Microsoft

First published on TECHNET on Jul 23, 2010

 

UPDATE:  Some of these commands have been changed for OpsMgr 2012, so I’ve created updated scripts at the bottom of this post that should work in 2012.

I’ve assisted a few customers with configuring Gateway Servers/Agents for failover lately, so I figured I’d post the commands that I use for this.

 

Why do we need to configure failover servers for Gateway Servers and Agents?
When an Agent is installed and configured to report to a Management Server, it is automatically configured to fail over to ANY other Management Servers.  So, if its assigned Management Server goes down, it will randomly pick any other Management Server in the Management Group to connect to (this could actually be a bad thing for large Management Groups, because some Agents will end up reporting to the RMS, which can cause performance problems….but that’s for a separate blog post).

When an Agent is installed and configured to report to a Gateway Server, no failover servers are automatically configured.  So, if the Gateway Server goes down, the Agents will not be able to send any data to the Management Group.

Also, when a Gateway Server is installed, it is configured to report to a specific Management Server and no failover is automatically configured.  So, if the Gateway Server’s Management Server goes down, the Gateway Server cannot send any data to the Management Group.

To handle the above scenarios, we must configure the Gateway Server to be able to connect to additional Management Servers, and we must configure the Gateway Agents to be able to connect to additional Gateway Servers.  This cannot be done in the OpsMgr Console, and must be done with PowerShell commands.

Notes:
If a Gateway Server is in a Domain that is not trusted by the Domain where OpsMgr is installed, then you will be using Certificates for the Gateway to authenticate with it’s Management Server.  If you configure the Gateway to be able to fail over to another Management Server, it (the failover Management Server) must also have an authentication Certificate installed and configured.

For the Gateway Agent Failover, if the Agents/Gateway are in a Domain that is not trusted by the Domain where OpsMgr is installed, then the Gateway Server that is used for Agent failover must be installed in this same domain (and must have an authentication Certificate installed and configured).

 

Here are the PowerShell commands that I use to configure and verify failover servers for Gateway Servers and Agents:

OpsMgr 2007:

Commands to configure Gateway Server Failover:

This first set of commands can be used to configure ALL Gateway Servers to use a specific Management Server as their Primary MS, and another Management Server for failover.  Replace PRI_MS.DOMAIN.COM and FAILOVER_MS.DOMAIN.COM with the names of the Primary and Failover Management Servers in your environment.

#Set all Gateway Servers to use PRI_MS and Primary and FAILOVER_MS as Failover
$primaryMS = Get-ManagementServer | where {$_.Name –eq 'PRI_MS.DOMAIN.COM'}
$failoverMS = Get-ManagementServer | where {$_.Name –eq 'FAILOVER_MS.DOMAIN.COM'}
$gatewayMS = Get-ManagementServer | where {$_.IsGateway -eq $true}
Set-ManagementServer -GatewayManagementServer: $gatewayMS -PrimaryManagementServer: $primaryMS -FailoverServer: $failoverMS

This next set of commands can be used if you have several Gateway Servers and don’t want them to all use the same Primary Management Server.  You specify the Gateway Server name (GATEWAY.DOMAIN.COM), the Primary Management Server Name (PRI_MS.DOMAIN.COM), and Failover Management Server name (FAILOVER_MS.DOMAIN.COM).

#Set specific Gateway Server to use PRI_MS and Primary and FAILOVER_MS as Failover
$primaryMS = Get-ManagementServer | where {$_.Name –eq 'PRI_MS.DOMAIN.COM'}
$failoverMS = Get-ManagementServer | where {$_.Name –eq 'FAILOVER_MS.DOMAIN.COM'}
$gatewayMS = Get-ManagementServer | where {$_.Name –eq 'GATEWAY.DOMAIN.COM'}
Set-ManagementServer -GatewayManagementServer: $gatewayMS -PrimaryManagementServer: $primaryMS -FailoverServer: $failoverMS

 

Commands to verify Gateway Server Failover:

After configuring the Gateway Server failover, you’ll want to verify the configuration.  The following PowerShell commands will output the name of each Gateway Server and its Primary and Failover Management Servers:

#Display Primary and Failover Management Servers for all Gateway Servers
$GWs = Get-ManagementServer | where {$_.IsGateway -eq $true}
$GWs | sort | foreach {
Write-Host "";
"Gateway MS    :: " + $_.Name;
"--Primary MS  :: " + ($_.GetPrimaryManagementServer()).ComputerName;
$failoverServers = $_.getFailoverManagementServers();
foreach ($managementServer in $failoverServers) {
"--Failover MS :: " + ($managementServer.ComputerName);
}
}
Write-Host "";

 

Commands to configure Gateway Agent Failover:

The commands for the Gateway Agent Failover will get all Agents that report to a specified Gateway Server and configure them to be able to failover to another Gateway Server.  Replace GATEWAY_1.DOMAIN.COM with the name of the Primary Gateway Server, and replace GATEWAY_2.DOMAIN.COM with the name of the Failover Gateway Server.

#Agents reporting to GATEWAY_1 - Failover to GATEWAY_2
$primaryMS = Get-ManagementServer | where {$_.Name –eq 'GATEWAY_1.DOMAIN.COM'}
$failoverMS = Get-ManagementServer | where {$_.Name –eq ' GATEWAY_2.DOMAIN.COM'}
$agent = Get-Agent | where {$_.PrimaryManagementServerName -eq 'GATEWAY_1.DOMAIN.COM'}
Set-ManagementServer -AgentManagedComputer: $agent -PrimaryManagementServer: $primaryMS -FailoverServer: $failoverMS

 

Commands to verify Gateway Agent Failover:

After configuring the Gateway Agent failover, you’ll want to verify the configuration.  The following PowerShell commands will output the name of each Agent that reports to GATEWAY_1.DOMAIN.COM and its Primary and Failover Gateway Servers:

#Verify Failover for Agents reporting to GATEWAY_1
$Agents = Get-Agent | where {$_.PrimaryManagementServerName -eq 'GATEWAY_1.DOMAIN.COM'}
$Agents | sort | foreach {
Write-Host "";
"Agent    :: " + $_.Name;
"--Primary MS  :: " + ($_.GetPrimaryManagementServer()).ComputerName;
$failoverServers = $_.getFailoverManagementServers();
foreach ($managementServer in $failoverServers) {
"--Failover MS :: " + ($managementServer.ComputerName);
}
}
Write-Host "";

 

 

OpsMgr 2012:

Commands to configure Gateway Server Failover:

This first set of commands can be used to configure ALL Gateway Servers to use a specific Management Server as their Primary MS, and another Management Server for failover. Replace PRI_MS.DOMAIN.COM and FAILOVER_MS.DOMAIN.COM with the names of the Primary and Failover Management Servers in your environment.

 

#Set all Gateway Servers to use PRI_MS and Primary and FAILOVER_MS as Failover
$primaryMS = Get-SCOMManagementServer | where {$_.Name –eq 'PRI_MS.DOMAIN.COM'}
$failoverMS = Get-SCOMManagementServer | where {$_.Name –eq 'FAILOVER_MS.DOMAIN.COM'}
$gatewayMS = Get-SCOMManagementServer | where {$_.IsGateway -eq $true}
Set-SCOMParentManagementServer -GatewayServer: $gatewayMS -PrimaryServer: $primaryMS
Set-SCOMParentManagementServer -GatewayServer: $gatewayMS -FailoverServer: $failoverMS

This next set of commands can be used if you have several Gateway Servers and don’t want them to all use the same Primary Management Server. You specify the Gateway Server name (GATEWAY.DOMAIN.COM), the Primary Management Server Name (PRI_MS.DOMAIN.COM), and Failover Management Server name (FAILOVER_MS.DOMAIN.COM).

#Set specific Gateway Server to use PRI_MS and Primary and FAILOVER_MS as Failover
$primaryMS = Get-SCOMManagementServer | where {$_.Name –eq 'PRI_MS.DOMAIN.COM'}
$failoverMS = Get-SCOMManagementServer | where {$_.Name –eq 'FAILOVER_MS.DOMAIN.COM'}
$gatewayMS = Get-SCOMManagementServer | where {$_.Name –eq 'GATEWAY.DOMAIN.COM'}
Set-SCOMParentManagementServer -GatewayServer: $gatewayMS -PrimaryServer: $primaryMS
Set-SCOMParentManagementServer -GatewayServer: $gatewayMS -FailoverServer: $failoverMS

Commands to verify Gateway Server Failover:

After configuring the Gateway Server failover, you’ll want to verify the configuration. The following PowerShell commands will output the name of each Gateway Server and its Primary and Failover Management Servers:

#Display Primary and Failover Management Servers for all Gateway Servers
$GWs = Get-SCOMManagementServer | where {$_.IsGateway -eq $true}
$GWs | sort | foreach {
Write-Host "";
"Gateway MS :: " + $_.Name;
"--Primary MS :: " + ($_.GetPrimaryManagementServer()).ComputerName;
$failoverServers = $_.getFailoverManagementServers();
foreach ($managementServer in $failoverServers) {
"--Failover MS :: " + ($managementServer.ComputerName);
}
}
Write-Host "";

Commands to configure Gateway Agent Failover:

The commands for the Gateway Agent Failover will get all Agents that report to a specified Gateway Server and configure them to be able to failover to another Gateway Server. Replace GATEWAY_1.DOMAIN.COM with the name of the Primary Gateway Server, and replace GATEWAY_2.DOMAIN.COM with the name of the Failover Gateway Server.

#Agents reporting to GATEWAY_1 - Failover to GATEWAY_2
$primaryMS = Get-SCOMManagementServer | where {$_.Name –eq 'GATEWAY_1.DOMAIN.COM'}
$failoverMS = Get-SCOMManagementServer | where {$_.Name –eq 'GATEWAY_2.DOMAIN.COM'}
$agent = Get-SCOMAgent | where {$_.PrimaryManagementServerName -eq 'GATEWAY_1.DOMAIN.COM'}
Set-SCOMParentManagementServer -Agent: $agent -PrimaryServer: $primaryMS
Set-SCOMParentManagementServer -Agent: $agent -FailoverServer: $failoverMS

Commands to verify Gateway Agent Failover:

After configuring the Gateway Agent failover, you’ll want to verify the configuration. The following PowerShell commands will output the name of each Agent that reports to GATEWAY_1.DOMAIN.COM and its Primary and Failover Gateway Servers:

#Verify Failover for Agents reporting to GATEWAY_1
$Agents = Get-SCOMAgent | where {$_.PrimaryManagementServerName -eq 'GATEWAY_1.DOMAIN.COM'}
$Agents | sort | foreach {
Write-Host "";
"Agent :: " + $_.Name;
"--Primary MS :: " + ($_.GetPrimaryManagementServer()).ComputerName;
$failoverServers = $_.getFailoverManagementServers();
foreach ($managementServer in $failoverServers) {
"--Failover MS :: " + ($managementServer.ComputerName);
}
}
Write-Host "";

%3CLINGO-SUB%20id%3D%22lingo-sub-365575%22%20slang%3D%22en-US%22%3EPowershell%20Commands%20to%20configure%20Gateway%20Server%20%2F%20Agent%20Failover%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-365575%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20Jul%2023%2C%202010%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20UPDATE%3A%26nbsp%3B%20Some%20of%20these%20commands%20have%20been%20changed%20for%20OpsMgr%202012%2C%20so%20I%E2%80%99ve%20created%20updated%20scripts%20at%20the%20bottom%20of%20this%20post%20that%20should%20work%20in%202012.%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EI%E2%80%99ve%20assisted%20a%20few%20customers%20with%20configuring%20Gateway%20Servers%2FAgents%20for%20failover%20lately%2C%20so%20I%20figured%20I%E2%80%99d%20post%20the%20commands%20that%20I%20use%20for%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhy%20do%20we%20need%20to%20configure%20failover%20servers%20for%20Gateway%20Servers%20and%20Agents%3F%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3EWhen%20an%20Agent%20is%20installed%20and%20configured%20to%20report%20to%20a%20Management%20Server%2C%20it%20is%20automatically%20configured%20to%20fail%20over%20to%20ANY%20other%20Management%20Servers.%26nbsp%3B%20So%2C%20if%20its%20assigned%20Management%20Server%20goes%20down%2C%20it%20will%20randomly%20pick%20any%20other%20Management%20Server%20in%20the%20Management%20Group%20to%20connect%20to%20(this%20could%20actually%20be%20a%20bad%20thing%20for%20large%20Management%20Groups%2C%20because%20some%20Agents%20will%20end%20up%20reporting%20to%20the%20RMS%2C%20which%20can%20cause%20performance%20problems%E2%80%A6.but%20that%E2%80%99s%20for%20a%20separate%20blog%20post).%3C%2FP%3E%0A%3CP%3EWhen%20an%20Agent%20is%20installed%20and%20configured%20to%20report%20to%20a%20Gateway%20Server%2C%20no%20failover%20servers%20are%20automatically%20configured.%26nbsp%3B%20So%2C%20if%20the%20Gateway%20Server%20goes%20down%2C%20the%20Agents%20will%20not%20be%20able%20to%20send%20any%20data%20to%20the%20Management%20Group.%3C%2FP%3E%0A%3CP%3EAlso%2C%20when%20a%20Gateway%20Server%20is%20installed%2C%20it%20is%20configured%20to%20report%20to%20a%20specific%20Management%20Server%20and%20no%20failover%20is%20automatically%20configured.%26nbsp%3B%20So%2C%20if%20the%20Gateway%20Server%E2%80%99s%20Management%20Server%20goes%20down%2C%20the%20Gateway%20Server%20cannot%20send%20any%20data%20to%20the%20Management%20Group.%3C%2FP%3E%0A%3CP%3ETo%20handle%20the%20above%20scenarios%2C%20we%20must%20configure%20the%20Gateway%20Server%20to%20be%20able%20to%20connect%20to%20additional%20Management%20Servers%2C%20and%20we%20must%20configure%20the%20Gateway%20Agents%20to%20be%20able%20to%20connect%20to%20additional%20Gateway%20Servers.%26nbsp%3B%20This%20cannot%20be%20done%20in%20the%20OpsMgr%20Console%2C%20and%20must%20be%20done%20with%20PowerShell%20commands.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENotes%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3EIf%20a%20Gateway%20Server%20is%20in%20a%20Domain%20that%20is%20not%20trusted%20by%20the%20Domain%20where%20OpsMgr%20is%20installed%2C%20then%20you%20will%20be%20using%20Certificates%20for%20the%20Gateway%20to%20authenticate%20with%20it%E2%80%99s%20Management%20Server.%26nbsp%3B%20If%20you%20configure%20the%20Gateway%20to%20be%20able%20to%20fail%20over%20to%20another%20Management%20Server%2C%20it%20(the%20failover%20Management%20Server)%20must%20also%20have%20an%20authentication%20Certificate%20installed%20and%20configured.%3C%2FP%3E%0A%3CP%3EFor%20the%20Gateway%20Agent%20Failover%2C%20if%20the%20Agents%2FGateway%20are%20in%20a%20Domain%20that%20is%20not%20trusted%20by%20the%20Domain%20where%20OpsMgr%20is%20installed%2C%20then%20the%20Gateway%20Server%20that%20is%20used%20for%20Agent%20failover%20must%20be%20installed%20in%20this%20same%20domain%20(and%20must%20have%20an%20authentication%20Certificate%20installed%20and%20configured).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20are%20the%20PowerShell%20commands%20that%20I%20use%20to%20configure%20and%20verify%20failover%20servers%20for%20Gateway%20Servers%20and%20Agents%3A%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20OpsMgr%202007%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20configure%20Gateway%20Server%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20first%20set%20of%20commands%20can%20be%20used%20to%20configure%20ALL%20Gateway%20Servers%20to%20use%20a%20specific%20Management%20Server%20as%20their%20Primary%20MS%2C%20and%20another%20Management%20Server%20for%20failover.%26nbsp%3B%20Replace%20PRI_MS.DOMAIN.COM%20and%20FAILOVER_MS.DOMAIN.COM%20with%20the%20names%20of%20the%20Primary%20and%20Failover%20Management%20Servers%20in%20your%20environment.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%23Set%20all%20Gateway%20Servers%20to%20use%20PRI_MS%20and%20Primary%20and%20FAILOVER_MS%20as%20Failover%20%3CBR%20%2F%3E%24primaryMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'PRI_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24failoverMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'FAILOVER_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24gatewayMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.IsGateway%20-eq%20%24true%7D%20%3CBR%20%2F%3ESet-ManagementServer%20-GatewayManagementServer%3A%20%24gatewayMS%20-PrimaryManagementServer%3A%20%24primaryMS%20-FailoverServer%3A%20%24failoverMS%3C%2FP%3E%0A%3CP%3EThis%20next%20set%20of%20commands%20can%20be%20used%20if%20you%20have%20several%20Gateway%20Servers%20and%20don%E2%80%99t%20want%20them%20to%20all%20use%20the%20same%20Primary%20Management%20Server.%26nbsp%3B%20You%20specify%20the%20Gateway%20Server%20name%20(GATEWAY.DOMAIN.COM)%2C%20the%20Primary%20Management%20Server%20Name%20(PRI_MS.DOMAIN.COM)%2C%20and%20Failover%20Management%20Server%20name%20(FAILOVER_MS.DOMAIN.COM).%3C%2FP%3E%0A%3CP%3E%23Set%20specific%20Gateway%20Server%20to%20use%20PRI_MS%20and%20Primary%20and%20FAILOVER_MS%20as%20Failover%20%3CBR%20%2F%3E%24primaryMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'PRI_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24failoverMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'FAILOVER_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24gatewayMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'GATEWAY.DOMAIN.COM'%7D%20%3CBR%20%2F%3ESet-ManagementServer%20-GatewayManagementServer%3A%20%24gatewayMS%20-PrimaryManagementServer%3A%20%24primaryMS%20-FailoverServer%3A%20%24failoverMS%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20verify%20Gateway%20Server%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAfter%20configuring%20the%20Gateway%20Server%20failover%2C%20you%E2%80%99ll%20want%20to%20verify%20the%20configuration.%26nbsp%3B%20The%20following%20PowerShell%20commands%20will%20output%20the%20name%20of%20each%20Gateway%20Server%20and%20its%20Primary%20and%20Failover%20Management%20Servers%3A%3C%2FP%3E%0A%3CP%3E%23Display%20Primary%20and%20Failover%20Management%20Servers%20for%20all%20Gateway%20Servers%20%3CBR%20%2F%3E%24GWs%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.IsGateway%20-eq%20%24true%7D%20%3CBR%20%2F%3E%24GWs%20%7C%20sort%20%7C%20foreach%20%7B%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%20%3CBR%20%2F%3E%22Gateway%20MS%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%3A%20%22%20%2B%20%24_.Name%3B%20%3CBR%20%2F%3E%22--Primary%20MS%26nbsp%3B%20%3A%3A%20%22%20%2B%20(%24_.GetPrimaryManagementServer()).ComputerName%3B%20%3CBR%20%2F%3E%24failoverServers%20%3D%20%24_.getFailoverManagementServers()%3B%20%3CBR%20%2F%3Eforeach%20(%24managementServer%20in%20%24failoverServers)%20%7B%20%3CBR%20%2F%3E%22--Failover%20MS%20%3A%3A%20%22%20%2B%20(%24managementServer.ComputerName)%3B%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20configure%20Gateway%20Agent%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20commands%20for%20the%20Gateway%20Agent%20Failover%20will%20get%20all%20Agents%20that%20report%20to%20a%20specified%20Gateway%20Server%20and%20configure%20them%20to%20be%20able%20to%20failover%20to%20another%20Gateway%20Server.%26nbsp%3B%20Replace%20GATEWAY_1.DOMAIN.COM%20with%20the%20name%20of%20the%20Primary%20Gateway%20Server%2C%20and%20replace%20GATEWAY_2.DOMAIN.COM%20with%20the%20name%20of%20the%20Failover%20Gateway%20Server.%3C%2FP%3E%0A%3CP%3E%23Agents%20reporting%20to%20GATEWAY_1%20-%20Failover%20to%20GATEWAY_2%20%3CBR%20%2F%3E%24primaryMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'GATEWAY_1.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24failoverMS%20%3D%20Get-ManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'%20GATEWAY_2.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24agent%20%3D%20Get-Agent%20%7C%20where%20%7B%24_.PrimaryManagementServerName%20-eq%20'GATEWAY_1.DOMAIN.COM'%7D%20%3CBR%20%2F%3ESet-ManagementServer%20-AgentManagedComputer%3A%20%24agent%20-PrimaryManagementServer%3A%20%24primaryMS%20-FailoverServer%3A%20%24failoverMS%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20verify%20Gateway%20Agent%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAfter%20configuring%20the%20Gateway%20Agent%20failover%2C%20you%E2%80%99ll%20want%20to%20verify%20the%20configuration.%26nbsp%3B%20The%20following%20PowerShell%20commands%20will%20output%20the%20name%20of%20each%20Agent%20that%20reports%20to%20GATEWAY_1.DOMAIN.COM%20and%20its%20Primary%20and%20Failover%20Gateway%20Servers%3A%3C%2FP%3E%0A%3CP%3E%23Verify%20Failover%20for%20Agents%20reporting%20to%20GATEWAY_1%20%3CBR%20%2F%3E%24Agents%20%3D%20Get-Agent%20%7C%20where%20%7B%24_.PrimaryManagementServerName%20-eq%20'GATEWAY_1.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24Agents%20%7C%20sort%20%7C%20foreach%20%7B%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%20%3CBR%20%2F%3E%22Agent%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%3A%20%22%20%2B%20%24_.Name%3B%20%3CBR%20%2F%3E%22--Primary%20MS%26nbsp%3B%20%3A%3A%20%22%20%2B%20(%24_.GetPrimaryManagementServer()).ComputerName%3B%20%3CBR%20%2F%3E%24failoverServers%20%3D%20%24_.getFailoverManagementServers()%3B%20%3CBR%20%2F%3Eforeach%20(%24managementServer%20in%20%24failoverServers)%20%7B%20%3CBR%20%2F%3E%22--Failover%20MS%20%3A%3A%20%22%20%2B%20(%24managementServer.ComputerName)%3B%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20OpsMgr%202012%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20configure%20Gateway%20Server%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20first%20set%20of%20commands%20can%20be%20used%20to%20configure%20ALL%20Gateway%20Servers%20to%20use%20a%20specific%20Management%20Server%20as%20their%20Primary%20MS%2C%20and%20another%20Management%20Server%20for%20failover.%20Replace%20PRI_MS.DOMAIN.COM%20and%20FAILOVER_MS.DOMAIN.COM%20with%20the%20names%20of%20the%20Primary%20and%20Failover%20Management%20Servers%20in%20your%20environment.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23Set%20all%20Gateway%20Servers%20to%20use%20PRI_MS%20and%20Primary%20and%20FAILOVER_MS%20as%20Failover%20%3CBR%20%2F%3E%24primaryMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'PRI_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24failoverMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'FAILOVER_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24gatewayMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.IsGateway%20-eq%20%24true%7D%20%3CBR%20%2F%3ESet-SCOMParentManagementServer%20-GatewayServer%3A%20%24gatewayMS%20-PrimaryServer%3A%20%24primaryMS%20%3CBR%20%2F%3ESet-SCOMParentManagementServer%20-GatewayServer%3A%20%24gatewayMS%20-FailoverServer%3A%20%24failoverMS%3C%2FP%3E%0A%3CP%3EThis%20next%20set%20of%20commands%20can%20be%20used%20if%20you%20have%20several%20Gateway%20Servers%20and%20don%E2%80%99t%20want%20them%20to%20all%20use%20the%20same%20Primary%20Management%20Server.%20You%20specify%20the%20Gateway%20Server%20name%20(GATEWAY.DOMAIN.COM)%2C%20the%20Primary%20Management%20Server%20Name%20(PRI_MS.DOMAIN.COM)%2C%20and%20Failover%20Management%20Server%20name%20(FAILOVER_MS.DOMAIN.COM).%3C%2FP%3E%0A%3CP%3E%23Set%20specific%20Gateway%20Server%20to%20use%20PRI_MS%20and%20Primary%20and%20FAILOVER_MS%20as%20Failover%20%3CBR%20%2F%3E%24primaryMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'PRI_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24failoverMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'FAILOVER_MS.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24gatewayMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'GATEWAY.DOMAIN.COM'%7D%20%3CBR%20%2F%3ESet-SCOMParentManagementServer%20-GatewayServer%3A%20%24gatewayMS%20-PrimaryServer%3A%20%24primaryMS%20%3CBR%20%2F%3ESet-SCOMParentManagementServer%20-GatewayServer%3A%20%24gatewayMS%20-FailoverServer%3A%20%24failoverMS%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20verify%20Gateway%20Server%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAfter%20configuring%20the%20Gateway%20Server%20failover%2C%20you%E2%80%99ll%20want%20to%20verify%20the%20configuration.%20The%20following%20PowerShell%20commands%20will%20output%20the%20name%20of%20each%20Gateway%20Server%20and%20its%20Primary%20and%20Failover%20Management%20Servers%3A%3C%2FP%3E%0A%3CP%3E%23Display%20Primary%20and%20Failover%20Management%20Servers%20for%20all%20Gateway%20Servers%20%3CBR%20%2F%3E%24GWs%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.IsGateway%20-eq%20%24true%7D%20%3CBR%20%2F%3E%24GWs%20%7C%20sort%20%7C%20foreach%20%7B%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%20%3CBR%20%2F%3E%22Gateway%20MS%20%3A%3A%20%22%20%2B%20%24_.Name%3B%20%3CBR%20%2F%3E%22--Primary%20MS%20%3A%3A%20%22%20%2B%20(%24_.GetPrimaryManagementServer()).ComputerName%3B%20%3CBR%20%2F%3E%24failoverServers%20%3D%20%24_.getFailoverManagementServers()%3B%20%3CBR%20%2F%3Eforeach%20(%24managementServer%20in%20%24failoverServers)%20%7B%20%3CBR%20%2F%3E%22--Failover%20MS%20%3A%3A%20%22%20%2B%20(%24managementServer.ComputerName)%3B%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20configure%20Gateway%20Agent%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20commands%20for%20the%20Gateway%20Agent%20Failover%20will%20get%20all%20Agents%20that%20report%20to%20a%20specified%20Gateway%20Server%20and%20configure%20them%20to%20be%20able%20to%20failover%20to%20another%20Gateway%20Server.%20Replace%20GATEWAY_1.DOMAIN.COM%20with%20the%20name%20of%20the%20Primary%20Gateway%20Server%2C%20and%20replace%20GATEWAY_2.DOMAIN.COM%20with%20the%20name%20of%20the%20Failover%20Gateway%20Server.%3C%2FP%3E%0A%3CP%3E%23Agents%20reporting%20to%20GATEWAY_1%20-%20Failover%20to%20GATEWAY_2%20%3CBR%20%2F%3E%24primaryMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'GATEWAY_1.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24failoverMS%20%3D%20Get-SCOMManagementServer%20%7C%20where%20%7B%24_.Name%20%E2%80%93eq%20'GATEWAY_2.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24agent%20%3D%20Get-SCOMAgent%20%7C%20where%20%7B%24_.PrimaryManagementServerName%20-eq%20'GATEWAY_1.DOMAIN.COM'%7D%20%3CBR%20%2F%3ESet-SCOMParentManagementServer%20-Agent%3A%20%24agent%20-PrimaryServer%3A%20%24primaryMS%20%3CBR%20%2F%3ESet-SCOMParentManagementServer%20-Agent%3A%20%24agent%20-FailoverServer%3A%20%24failoverMS%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Commands%20to%20verify%20Gateway%20Agent%20Failover%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAfter%20configuring%20the%20Gateway%20Agent%20failover%2C%20you%E2%80%99ll%20want%20to%20verify%20the%20configuration.%20The%20following%20PowerShell%20commands%20will%20output%20the%20name%20of%20each%20Agent%20that%20reports%20to%20GATEWAY_1.DOMAIN.COM%20and%20its%20Primary%20and%20Failover%20Gateway%20Servers%3A%3C%2FP%3E%0A%3CP%3E%23Verify%20Failover%20for%20Agents%20reporting%20to%20GATEWAY_1%20%3CBR%20%2F%3E%24Agents%20%3D%20Get-SCOMAgent%20%7C%20where%20%7B%24_.PrimaryManagementServerName%20-eq%20'GATEWAY_1.DOMAIN.COM'%7D%20%3CBR%20%2F%3E%24Agents%20%7C%20sort%20%7C%20foreach%20%7B%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%20%3CBR%20%2F%3E%22Agent%20%3A%3A%20%22%20%2B%20%24_.Name%3B%20%3CBR%20%2F%3E%22--Primary%20MS%20%3A%3A%20%22%20%2B%20(%24_.GetPrimaryManagementServer()).ComputerName%3B%20%3CBR%20%2F%3E%24failoverServers%20%3D%20%24_.getFailoverManagementServers()%3B%20%3CBR%20%2F%3Eforeach%20(%24managementServer%20in%20%24failoverServers)%20%7B%20%3CBR%20%2F%3E%22--Failover%20MS%20%3A%3A%20%22%20%2B%20(%24managementServer.ComputerName)%3B%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3EWrite-Host%20%22%22%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-365575%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20TECHNET%20on%20Jul%2023%2C%202010%20%26nbsp%3B%20UPDATE%3A%26nbsp%3B%20Some%20of%20these%20commands%20have%20been%20changed%20for%20OpsMgr%202012%2C%20so%20I%E2%80%99ve%20created%20updated%20scripts%20at%20the%20bottom%20of%20this%20post%20that%20should%20work%20in%202012.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-365575%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EJimmyHarper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Feb 20 2020 11:14 AM
Updated by: