By default, you can’t really specify a failover management server in OpsMgr. Why? Not really sure, though I think it’s a ploy to ensure you setup the OpsMgr Active Directory Integration, which will handle this for you.
No fret though, we can still do it – it’ll just take a little bit of actual effort.
First, we need to define our Primary and Failover management servers. This isn’t something you can just progmatically grab, so you’ll need to know the name yourself.
In my $PROFILE, I’ve set them to be defined to 2 variables with the following:
|
1 2 3 4 |
# Set Primary Management Server $Primary_MS = Get-ManagementServer | ? {$_.Name -like "SERVERNAME*"} # Set Failover Management Server $Failover_MS = Get-ManagementServer | ? {$_.Name -like "BACKUPSERVER*"} |
Now that we have that set, it’s simple to do the rest. First, lets grab all of the servers that don’t have a failover management server set.
|
1 |
$noFailoverSpecified = Get-Agent | ? {(!$_.GetFailoverManagementServers())} |
What the above does is call the GetFailoverManagementServers() method on each agent. If they have a failover, it will return data and thus $True. If there aren’t any failovers, it will return nothing – which is the same as $False. So we look for all the ones that don’t return anything.
If you’re curious, you can see just how many servers are missing failovers with
|
1 |
$noFailoverSpecified.Count |
- in my case it was 63.
Now, we just run a quick snippet that adds the failover server to the agent:
|
1 2 3 |
ForEach ($agent in $noFailoverSpecified) { Set-ManagementServer -PrimaryManagementServer $Primary_MS -AgentManagedComputer $agent -FailoverServer $Failover_MS | Out-Null } |
That will crunch away as it’s doing it’s thing, we’re redirecting output to $null so we don’t have to see agents scrolling over and over. When it returns you to a prompt, you’re done. If you’d like to verify that you did indeed set all of the agents to have a failover, we can check real quick:
|
1 2 3 4 5 6 |
If ((Get-Agent |? {(!$_.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 } |
And that’s that. All of your agents have a primary and failover server.
But wait, you have a lot of remotely managed devices too? Monitoring SNMP on a bunch of different servers – what happens for that?
Well, we can’t setup a failover (From what I’ve seen, if I’m wrong please let me know) agent. But we can proactively write a script that will change the proxy agent on the devices, and run it as needed.
This was written in a response to this query on the newsgroups, and is only a cursory look into it. There may be other ways of doing this – and I’d love to hear it. As it stands, I’m not sure how to set them back to a management server as the monitor.
Firstly, we’ll have to pick an agent managed computer to use as the new proxy agent. You can’t use a management server for this, because they aren’t “Agent Managed” and you can’t use Set-ManagementServer because the devices aren’t “Remote Managed Computers”. I have a seperate agent-managed server on my network I call “Timex” because it acts like a watcher node. So I’ll go ahead and use him.
|
1 |
$proxyAgent = Get-Agent |? {$_.Name -eq "timex.pavleck.net"} |
Then gather a list of our current remotely managed devices
|
1 |
$remDevices = Get-RemotelyManagedDevice |
Now just loop through it, setting the device to use the proxy agent we just instantiated:
|
1 2 3 |
ForEach($device in $remDevices) { Set-ProxyAgent -ProxyAgent $proxyAgent -Device $device | Out-Null } |
That will loop through things changing the proxy server that it uses. When it’s done, we can verify it by running:
|
1 |
Get-RemotelyManagedDevice |? {$_.ProxyAgentPrincipalName -ne $proxyAgent.Name} |
If it outputs nothing, then they’ve all been changed. Simple as that!



In my Lab I use my RMS as the Defaut Proxy Agent for my SNMP device. And it seems to work fine. And if RMS is installed on a MCSC cluster, it could answer or not ?
I think if you’re running it on a cluster, then you don’t have much to worry about – since the monitoring would still occur from one of the nodes if one went down. Nice setup!
After running the commands i have one question open:
How do i verify on the target computer the agent settings for primary of fail over management server?
regards
HB