Because of some issues arising on a large SCOM environment, I decided to work with PowerShell to create and run a script to see if the SCOM Agents has a Failover Management server.
Note: Use PowerShell to your advantage. It is a powerful tool to have in your arsenal.
Start off by getting the members of the "Get-SCOMAgent" PowerShell command
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.
Here is what the final product is looking like:
Param([string] $parameter)
Import-Module OperationsManager;
$ErrorActionPreference = "silentlycontinue";
If (!($parameter -eq ""))
{
$agents = Get-SCOMAgent $parameter
}
else
{
$agents = Get-SCOMAgent
};
ForEach ($agent in $agents)
{
"=" * 100
Write-Host -ForegroundColor White ("Server Agent: " + " "*40 + $agent.DisplayName);
If (($agent.GetPrimaryManagementServer()).IsGateway -eq $true)
{
Write-Host -ForegroundColor Green ("Primary Management Server [Gateway]: " + " "*17 + ($agent.GetPrimaryManagementServer()).DisplayName)
}
else
{
Write-Host -ForegroundColor Green ("Primary Management Server: " + " "*27 + ($agent.GetPrimaryManagementServer()).DisplayName)
};
$failover = $agent.GetFailoverManagementServers();
ForEach ($server in $failover)
{
Write-Host -ForegroundColor Red ("Failover Server: " + " "*37 + $server.DisplayName)
};
};
You can run the script with or without parameters.
.\GetFailoverManagementServer.ps1 "Server.Domain.com"
or
.\GetFailoverManagementServer.ps1
Without parameters you will get the info for all of the SCOM Agents. With a parameter you will only get the info for that specific server.
Hope that this post was helpful.
PS: Would like to thank Stefan Roth for the inspiration.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.