This will set a failover Management Server for a Gateway role, leaving the currently configured primary Management Server.

Beware of word wrap on the last two lines (should be one line).

$gw = get-GatewayManagementServer | where {$_.Name -eq "gw_fqdn"}
$pms = $gw | get-PrimaryManagementServer
$fms = get-ManagementServer | where {$_.Name -eq "failover_fqdn"}
set-ManagementServer -GatewayManagementServer: $gw -PrimaryManagementServer: $pms -FailoverServer: $fms

 

Verify primary and failover Management Servers with the following.

$gw | foreach-object {
$_.getPrimaryManagementServer() | select Name
$_.getFailoverManagementServers() | select Name}

 

command shell main menu