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.
.\Get-FailoverManagementServer.ps1 “server.domain.com”
or
.\Get-FailoverManagementServer.ps1
The script looks like this…
…and you can download it here.
Cheers,
Stefan
Is there a way to dump this information to a csv?
Hi Superman
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.
Cheers,
Louise Lane
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.