One of the nice things about SCOM2007 is the ease in which you can monitor and manage non-Windows devices (Even better with the dhjdhdhdhd addon). Being able to add your switches, routers and Unix devices makes for a more complete overview of the health of your system.
There is a downfall though, and that would be that although you can use Get-RemotelyManagedDevice in the Command shell to list the, umm, remotely managed devices, all it will return is the IP address.
Here’s a SCOM command shell one-liner that will use some .Net-Fu to reverse the IP for you, on the fly:
|
1 |
Get-RemotelyManagedDevice | ForEach-Object {Write-Host "IP $($_.Name) resolves to hostname $([System.Net.Dns]::GetHostByAddress($_.Name).HostName)" } |
If you want, you can go a step further and add it to your profile (Or more preferably, a SCOM snippet file that I’ll be writing about later.) and pull it up anytime you want.
The Display-NetAgentsByHostName function has one parameter, -short. Run the default ‘long’ way, it will reverse the IP, list the client that is managing it, the management group and the health state.
With the -short switch, it simply outputs health state, host name and IP address.
It’s not perfect, and coult use some formatting, but it works as is, so I leave it up as an exercise to the reader to polish it some more ![]()
Page formatting messing it up? I’ll fix it some day – until then, download Display-NetAgentsByHostName.ps1
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
function Display-NetAgentsByHostName([switch]$short) { function LookUp([string]$ip) { trap { "Unable to resolve IP" continue; } ([System.Net.Dns]::GetHostByAddress($ip)).HostName } Get-RemotelyManagedDevice | ForEach-Object { If (!$short) { If ($_.HealthState -eq "Success") { Write-Host ("IP Address $($_.Name) resolves to '$(Lookup($_.Name))' - Managed by server: $($_.ProxyAgentPrincipalName.Split('.;')[0])" + "in Management group: $($_.ManagementGroup) - Health State: $($_.HealthState)`n") -ForeGroundColor Green } elseif ($_.HealthState -eq "Warning") { Write-Host ("IP Address $($_.Name) resolves to '$(Lookup($_.Name))' - Managed by server: $($_.ProxyAgentPrincipalName.Split('.;')[0])" + "in Management group: $($_.ManagementGroup) - Health State: $($_.HealthState)`n") -ForeGroundColor Yellow } elseif ($_.HealthSTate -eq "Error") { Write-Host ("IP Address $($_.Name) resolves to '$(Lookup($_.Name))' - Managed by server: $($_.ProxyAgentPrincipalName.Split('.;')[0])" + "in Management group: $($_.ManagementGroup) - Health State: $($_.HealthState)`n") -ForeGroundColor Red } } else { If ($_.HealthState -eq "Success") { Write-Host "HEALTHY - Host: $(Lookup($_.Name)) - IP: $($_.Name)" -ForeGroundColor Green } elseif ($_.HealthState -eq "Warning") { Write-Host "HEALTH WARNING! State: $($_.HealthState) - Host: $(Lookup($_.Name)) - IP: $($_.Name)" -ForeGroundColor Yellow } elseif ($_.HealthState -eq "Error") { Write-Host "HEALTH ERROR! State: $($_.HealthState) - Host: $(Lookup($_.Name)) - IP: $($_.Name)" -ForeGroundColor Red } } } } |

