Because of an issue I needed to get the failover management servers of the agents. Well, because I like to fool around with Powershell I thought I would write a short script.
Just to give you some background how I figured it out. First I got the members of the Get-SCOMAgent command by typing:
Get-SCOMAgent | Get-Member
You will likely see something like this…
As you see GetFailoverManagementServers is a collection, therefore this method could contain more than one entry. PrimaryManagementServerName is just a simple string property so we don’t have to do anything special.
With this background I wrote this script which dumps all agents with its primary management server and its failover server. It also indicates if the primary management server is a gateway or not.
You can call the script with an agent name and the script will dump just the servers for the one agent or without any parameter it just dumps the information for all agents.
The script looks like this…
…and you can download it here.
4 Replies to “SCOM 2012 – Get Agent Failover Management Server”
Is there a way to dump this information to a csv?
Sure, instead of using Write-Host just dump the string data into a file like this
“My Text” | Out-File -FilePath c:tempfile.txt -Append
Of course you need to fit it into the script accordingly, but this shouldn’t be a problem for Superman.
Would I need to just replace the Write-Host -ForegroundColor Red (“Failover Server: ” + ” “*37 + $server.DisplayName) or every Write-Host entry?
Thanks a lot Stefan. Helped me very much.