Script

SCOM 2012 – Server Boot Check and Availability HTML Report (PowerShell Script)

As there are many good ideas out there and so many bright minds, you just have to pull all this energy together mix it with your own ideas and you will create wonderful things.

A practical example would be the following story. A customer who likes simple things came up with an idea. Imagine you have a monthly maintenance window in your company where you are going to patch all your servers. As good practice you will put all your lovely servers into maintenance mode, great! After you applied your patches and you rebooted (?) your servers you probably want to check if all your servers rebooted, are up and running and healthy in SCOM.

Now the thing is, are you sure ALL your servers booted within your maintenance window? If you see a green agent in the SCOM console doesn’t guarantee you that the server rebooted. What if there are service desk guys who don’t know anything about SCOM and need a quick check to see if the server booted and is healthy, meaning available in SCOM.

Of course one approach could be creating rules which detect boot event id’s from each server and if the server does not generate such an event id it will throw an alert and so on, but honestly, don’t we have already enough alerts in SCOM Smiley?

Inspired by the idea from the customer and by a blog post from this bright PowerShell guy Thiyagu here  I wrote a PowerShell script which generates an HTML report. I adapted Thiyagu’s way of generating an HTML file in PowerShell, therefore all credits to him.

OK what is it all about…

1) First download the script from here
2) Run the Get-BootAvailabilityReport.ps1 providing 3 parameters

  • uptimethreshold – This parameter defines how old is your maintenance window. Let’s say you finished patching and rebooting all your servers and every server is no longer up than 60 hours (in this example). If a server has an uptime more than 60 hours the server did not reboot.
  • filename – Output path where you want to have the report file written e.g. c:\temp\report.html (must be a valid directory and a *.html file name)
  • scom – SCOM management server which the script connects to.

image

3) After the script finished Internet Explorer opens and presents you a nice report

image

The report contains  6 columns:

  • Server Name – This is the name of the server
  • Last Boot Time – This is the time the server booted last
  • Server Uptime – How long the server is up and running
  • Server Uptime (Total Hours) – How long the server is up and running in hours
  • Last Agent Health State – Last status of the agent health in SCOM
  • Agent Available – Shows if the agent is available (=True) or e.g. grey (=False)

How to deal with it…

  • The uptimethreshold parameter which you provide to the script is compared against the Server Uptime (Total Hours). If the Server Uptime (Total Hours) is greater than the uptimethreshold  it will be colored red.
  • If the Last Agent Health State has another result than Success it will be appear in red.
  • If the Agent Available has another value than True it will be appear in red.

So that means if the last 3 column are colored green everything is ok. If Server Uptime (Total Hours) is red the server did not reboot. If Agent Available is colored red the SCOM agent is not available. The Last Agent Health State shows only the last health state the agent had in SCOM. This could be misleading, because if an agent is grey in SCOM and didn’t have a critical health state before it went grey this column will appear green.

I hope you get the idea behind and you like it as much I do.

The script uses the SCOM 2012 cmdlet’s and also WMI to query the servers. Make sure you have the necessary permissions and ports available for the script to run properly.

Download the script, have fun!

24 Replies to “SCOM 2012 – Server Boot Check and Availability HTML Report (PowerShell Script)

  1. Hello Stefan,

    Very good morning, I need your help in getting out the problem. The problem is i work on SCOM 2012 where i need to monitor SQL Azure and BLOB Storage in SCOM 2012 but as per the microsoft | scom 2012 won’t support sql, How ever there are some instance were we can change the settings and can do the installation of SQL Azure in SCOM 2012 [availability Monitoring] can you please help me in doing the configuration.

    Thank you So much.

    Regards,
    ShivaJ

  2. Hi there,
    A very useful report to add to the toolbox, however it appears to be limited to a single domain. Is there any way we can execute the WMI query through SCOM/certificate credentials to agents in untrusted domains?

    1. Hi

      For a specific server just use $agents = Get-SCOMAgent | Where-Object {$_.DisplayName -eq “serverxy.domain.com”} instead $agents= Get-SCOMAgent in the script.

      Cheers,

      Stefan

    1. Hi

      Yes this is easily possible, you would have to just slightly modify the script the line $agents= Get-SCOMAgent to $agents = Get-SCOMGroup -DisplayName “All Windows Computers” | Get-SCOMClassInstance | Get-SCOMAgent and just replace the “All Windows Computers” name through your group name. I didn’t test it but it should work :).

      Cheers,
      Stefan

  3. link doesnt allow me to download buddy, if possible can you mail me the same and also can you confrim does it use multiple threads to check the details or it checks one by one, also does it usage a server list to check all these details.

    1. Hi

      I just cheked the link works. It goes one by one in a “foreach” of course you could modify it to run in parallel. It uses the SCOM management server to query the server.

      Cheers,

      Stefan

  4. there are servers that are showing up without a hostname

    LIHBGLABWW03 Thursday, February 12, 2015 5:16:54 AM 7 Days 11 Hours 7 Minutes 179 Success True
    LIHBGLABMD02 Thursday, February 12, 2015 4:14:35 PM 7 Days 0 Hours 10 Minutes 168 Success True
    Thursday, February 12, 2015 4:14:35 PM 7 Days 0 Hours 10 Minutes 168 Success True
    LIHBGLABAPE3 Wednesday, February 11, 2015 5:21:11 AM 8 Days 11 Hours 3 Minutes 203 Success True

    Suggestions??

  5. what to modified to make it work on SCOM2007R2. What is scom2007 class name for agent

    Microsoft.SystemCenter.Agent

  6. Hello, I would like to see the domains controller, how do I do? thank you for your script

    Best Regards

  7. Hi Stefan,

    This is great script. Im unable to execute it on my SCOM 2012 setup, the script get executed without any error, but the report is empty. Pls help.

    Regards,
    Sameer

  8. Hi Stefan,

    how i can have a extra filed in a report for IP address colume and populate the IP address of agent in a report.

    Thanks,
    Anil

  9. Hi Stefan,

    Great report. Can you please help to make the report to send to email.As the content as email body.

  10. Thank you for sharing the great work!
    By any chance, do you have sql script for the same output?
    Many Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.