Agent failover behind gateway servers
Home  » Agent failover behind gateway servers

Agent failover behind gateway servers
Posted: Fri, Jun 05, 2009 12:21 PM :: Rank: 96
Author
Points: 10290
Level: System Center Expert

Hello Everyone,

I set up agent failolver behind gateway servers,  which i used following powershell script.;

$primaryGW= Get-ManagementServer | where {$_.Name –eq 'primarygws.test.com'}
$failoverGw = Get-ManagementServer | where {$_.Name –eq 'failovergws.test.com'}
$agents = Get-Agent | where {$_.primarymanagementservername -eq 'primarygws.test.com'}
Set-ManagementServer -AgentManagedComputer: $agents -PrimaryManagementServer: $primaryGW -FailoverServer: $failoverGw

everything works fine, my question is

How can I make sure and see agents failover gateway servers settings? 

 

Thank you.

   Report Abuse
Re: Agent failover behind gateway servers
Posted: Fri, Jun 05, 2009 3:42 PM :: Rank: 128
Author
Points: 65442
Level: System Center Expert

 You would like to confirm the agent has a failover management server (or gateway in this case) configured? This is not exposed as a property through a simple get-agent one-liner, but there is a method you can use to retrieve this information.

Try the following and let me know if this is what you are looking for. 

$agent = get-agent | where {$_.Name -match 'computername' }

$agent.getfailovermanagementservers()

Output should be a list of failover management servers for the target agent.

 

   Report Abuse
Re: Agent failover behind gateway servers
Posted: Fri, Jun 05, 2009 4:08 PM :: Rank: 127
Author
Points: 10290
Level: System Center Expert
Thank you Pete, that is exactly what I was looking for . You are the man : ) Thanks again
   Report Abuse
RE: Agent failover behind gateway servers
Posted: Fri, Nov 06, 2009 4:48 PM :: Rank: 72
Author
Points: 5
Level: System Center Enthusiast

Got  a problem with a remote site agent failover conifguration. The failover setting will not update on the agents when I execute my powershell script.

My script finds agents without failover configured but fails to update or change the failover settings. Yet when I do an agent failover query it shows the PrimaryMS is set to the proper Gtw server, but with multiple incorrect  FailoverMS. My MS and RMS servers are listed as failovers for most of the agents.

I get the following error when the script tries to set the PrimaryMS and FailoverMS:

Set-ManagementServer : Cannot convert 'System.Object[]' to the type 'Microsoft.
EnterpriseManagement.Administration.ManagementServer' required by parameter 'PrimaryManagementServer'. Specified method is not supported.
At C:\DOCUME~1\SCOMPR~1\LOCALS~1\Temp\955fe512-90d1-4f91-b88e-ff56a897b781.ps1:
75 char:46
+ Set-ManagementServer -PrimaryManagementServer  <<<< $Primary_MS
`

Here is script:

# Set MS servers
$Primary_MS = Get-ManagementServer | ? {$_.Name -like "servername*"}
$Failover_MS = Get-ManagementServer | ? {$_.Name -like "servername*"}

$Correct = read-Host -Prompt "Continue? (Y|N) > "
if ($Correct -ieq "N"){Break}

Write-Host "Retrieving agents with no Failover Configured."
$noFailoverSpecified = Get-Agent | where {$_.name -ilike '*' -and `
  $_.PrimaryManagementServerName -like 'servername*'} `
  | ? {(!$_.GetFailoverManagementServers())}
  
if ($noFailoverSpecified -ne $null)
{
Write-Host "Total Agents found with no Failover Configured."
write-Host "Count: " $noFailoverSpecified.Count
}
Else
{
Write-Host "No Failover specified."
write-Host "Count: " $noFailoverSpecified.Count
}
$Correct = read-Host -Prompt "Continue? (Y|N)> "
if ($Correct -ieq "N"){Break}

ForEach ($agent in $noFailoverSpecified)
{
Set-ManagementServer -PrimaryManagementServer $Primary_MS `
 -AgentManagedComputer $agent -FailoverServer $Failover_MS # | Out-Null
}

If ((Get-Agent | where {$_.PrimaryManagementServerName -like 'servername*'} `
  |? {(!$_.GetFailoverManagementServers())}).Count -eq $null)
{ Write-Host "Every agent has a failover server, great job!" -ForeGroundColor Green }
else { Write-Host "Looks like we missed some, try again!" -ForeGroundColor Magenta }

 

Thanks , George

Accepted Answer
   Report Abuse

Home  » Agent failover behind gateway servers
Top Contributors
Featured Members
Pete Zerger
Points: 65442
Level: System Center Expert
Tommy Gunn
Points: 42712
Level: System Center Expert
Simon Skinner
Points: 40744
Level: System Center Expert
Stefan Koell
Points: 28999
Level: System Center Expert
Andreas Zuckerhut
Points: 27434
Level: System Center Expert