We are running an implementation where we will be taking down our management servers for maintenance.
I want to run a powershell script that will:
a.Determine mgt server is healthy - I have a script to do this so checked off
b.Determine that the management server is assigned to the proper resource pool. I have this script which looks pretty good.
PS H:\Users\la-wh24xu> New-SCOMManagementGroupConnection -ComputerName scomprdatacenter
$ResourcePools = Get-SCOMResourcePool
$ManagementServers = @{}
foreach ($Pool in $ResourcePools) {
foreach ($Member in $Pool.Members) {
#$Member.DisplayName
If ($ManagementServers.ContainsKey($Member.DisplayName)) {
$tmpArray = $ManagementServers.Item($Member.DisplayName)
$tmpArray += $Pool.DisplayName
$ManagementServers.Set_Item($Member.DisplayName,$tmpArray)
} else {
$ManagementServers.Add($Member.DisplayName,@($Pool.DisplayName))
}
}
}
foreach ($ManagementServer in $ManagementServers.Keys) {
$PoolCount=$ManagementServers.Item($ManagementServer).Count
If ($PoolCount -gt 1) {
Write-Output "Management Server $ManagementServer is assigned to $PoolCount resource pools: $($ManagementServers.Item($ManagementServer) -Join ', ')"
}
}
c.I want to determine in the script the total agent count that is reporting to the management server/resource pool that is in healthy and unhealthy state.
Thanks in advance.