1. First
list all Agents with Primary and Secondary MS/Gateway Server
#list all agents with Primary and Secondary
servers
get-agent|ft -a ComputerName,primarymanagementservername,@{l=”secondary”;e={$_.getfailovermanagementservers()|foreach{$_.name}}}
get-agent|ft -a ComputerName,primarymanagementservername,@{l=”secondary”;e={$_.getfailovermanagementservers()|foreach{$_.name}}}
2. Second,
isolate all agents which report to Primary MS/Gateway Server
#Verify Failover for Agents reporting to FQDN_of_primaryMS
$Agents = Get-Agent | where {$_.PrimaryManagementServerName -eq ‘FQDN_of_primaryMS‘}
$Agents | sort | foreach {
Write-Host “”;
“Agent :: ” + $_.Name;
“–Primary MS :: ” + ($_.GetPrimaryManagementServer()).ComputerName;
$failoverServers = $_.getFailoverManagementServers();
foreach ($managementServer in $failoverServers) {
“–Failover MS :: ” + ($managementServer.ComputerName);
}
}
Write-Host “”;
3. Third,
set Failover MS/Gateway failoverMS for all
agents which report to Primary FQDN_of_primaryMS
#Agents reporting to FQDN_of_primaryMS –
Failover to FQDN_of_failoverMS $primaryMS = Get-ManagementServer | where {$_.Name –eq ‘FQDN_of_primaryMS‘}
$failoverMS = Get-ManagementServer | where {$_.Name –eq ‘FQDN_of_failoverMS‘}
$agent = Get-Agent | where {$_.PrimaryManagementServerName -eq ‘FQDN_of_primaryMS‘}
Set-ManagementServer -AgentManagedComputer: $agent -PrimaryManagementServer: $primaryMS -FailoverServer: $failoverMS