Output displayname and IP address for SCOMagents

Got bored – wrote this little thing to output FQDN and IPaddress for all Windows and UnixLinux agents in my lab environment.

Could be useful for some people maybe.

ipmo operationsmanager
$nixservers = get-scomclass -name "Microsoft.Unix.Computer" | Get-SCOMMonitoringObject
$winservers = Get-SCOMClass -name "Microsoft.Windows.Computer" | Get-SCOMMonitoringObject

    Write-host "-----------------------------------------------------------------"
    write-host "-------------------- Unix Computers and IPs ---------------------"
    Write-host "-----------------------------------------------------------------"
foreach ($nix in $nixservers) 

        write-host ([System.Net.Dns]::GetHostAddresses($nix) | foreach {echo $nix - $_.IpAddressToString})

    Write-host "-----------------------------------------------------------------"
    write-host "------------------- Windooze Computers and IPs ------------------"
    Write-host "-----------------------------------------------------------------"
foreach ($win in $winservers) 

        write-host ([System.Net.Dns]::GetHostAddresses($win) | foreach {echo $win - $_.IpAddressToString})

Thank god it’s Friday…


Monitor Active/Passive Clustered Services… in SCOM?

I was playing around in Powershell the other day, and made this little thingy to help me monitor clustered Windows Services in an Active/Passive Windows Cluster solution.
The script checks if specific Windows Services are running or not, and determines which node is active in the cluster by using the get-wmiobject cmdlet.

There are many different uses for this, and can easily be modified to for example create events on the server you’re executing the script from.

This is also a really easy way to monitor Clustered Active/Passive services in Operations Manager, which is a REAL pain to do without making some overly complicated Service Monitors.
Why complicated you ask? Clusterservers do not have SCOM Agents installed,only the logical clusternode has agents. Read more about this here.
Alternatively you can do it like the pros do, and add intelligence to the monitors, described here.

Wow that was some sidetrack – enough fufflin’ around! Let’s look at this awesome script!

# Monitor Clustered Windows Services v 1.0
# www.fuffle.net

$getcluster = Get-WmiObject win32_computersystem -computername {"ENTER LOGICAL CLUSTERNAME HERE"} | select-object name
$activenode = $getcluster.name
$cluservice = 'BTSSvc$SingleReceiveHost','BTSSvc$SingleReceiveHost32','BTSSvc$SingleSendHost','BTSSvc$SingleSendHost32','BTSSvc$SingleWcfSqlHost','w3svc','Btsaalsvc','ENTSSO','RuleEngineUpdateService'

# Alternativly you can list all servicenames in a file - uncomment line 10 and comment line 7
#$cluservice = get-content "C:tempservicelist.txt"

foreach ($node in $activenode)

$service = get-service -computername $activenode $cluservice | Select-Object Status,Name,displayname

# Check all services for state, then write out result
foreach ($s in $service)
    # If services are in a "running" state
    if($service.status -eq "running")
    {write-host "The service" $s.displayname "is running on active clusternode" $getcluster.name"- All is well."}
        # If services are in a "stopped" state
        elseif($service.status -eq "stopped")
        {write-host "The service" $s.displayname "has stopped on active clusternode" $getcluster.name"- Some poo has hit the fan."}
            # If services are in a different state than "Running" or "Stopped"
            {write-host "The service" $s.displayname "is returning with status" $service.status "- Investigate this on " $getcluster.name}

Feel free to contact me if you have any questions or remarks about the script. I am a Powershell newbie, and I have no doubt that there is some better way to do this sort of thing.

– F