Custom SCOM Dashboard with PowerShell Grid Widget

A while ago I wanted to create a simple Dashboard which uses PowerShell Grid Widget. I soon found this article.

So I started from there..

The scenario I wanted to do is to get status and uptime of computers which I select in SCOM Dashboard. And the outcome was this:

CreateNewDashboard12

If you want to know how to do it read more 😉

Let’s get our hands dirty then:

  1. Right Click Where you want to put your new dashboard:

CreateNewDashboard1

2.   Select Grid Layout:

CreateNewDashboard2

  1. Give it a Name and optionally description:

CreateNewDashboard3

  1. Select Number of Cells and Layout

CreateNewDashboard4

  1. Click Create => Close

6.   Click on “Click to add widget…

CreateNewDashboard5

7.   Click on Template so Widgets are arranged by name => Select State Widget => Next

CreateNewDashboard6

8.   Give it a Name and Click Next

CreateNewDashboard7

9.   Click on (…) under “Select a class to scope the members of specified groups => browse for Windows Computer and select it:

CreateNewDashboard8

10.  Click OK => Next two times

  1. Specify Display Preferences (I chose Health and Display Name with Sort by: Health) => Finish

CreateNewDashboard9

12.  Then we Click Again on “Click to add widget.. to add PowerShell Grid Widget. Use same procedure as before. But now chose PowerShell Grid Widget Template

CreateNewDashboard10

13.  Give it a name => Next => Then paste in PowerShell Script => Click Next => Create => Close

And we are done. Now test it by choosing desired Servers. 😉

CreateNewDashboard12

 

And here is PowerShell Script.

 
Param($globalSelectedItems)
 
foreach ($OneItem in $globalSelectedItems){
 
    $OneItemInstance = Get-SCOMClassInstance -Id $OneItem["Id"]
 
    $Uptime = Invoke-Command -ComputerName $OneItemInstance.DisplayName -ScriptBlock {
        $CurrentDate=Get-Date
        $Win32osClass=Get-WmiObject -Class Win32_OperatingSystem
 
        $Days=(($CurrentDate) – ([WMI]“”).ConverttoDateTime(($Win32osClass).LastBootUpTime)).Days 
        $Hours=(($CurrentDate) – ([WMI]“”).ConverttoDateTime(($Win32osClass).LastBootUpTime)).Hours
        $Minutes=(($CurrentDate) – ([WMI]“”).ConverttoDateTime(($Win32osClass).LastBootUpTime)).minutes
        "System Uptime is: $Days Day(s) $Hours Hour(s) $Minutes Minute(s)"
    }
    
    if (Test-Connection -ComputerName $OneItemInstance.DisplayName -Count 1 -ErrorAction Stop -Quiet){
    $TestConn = "Ho ho ho merry Christmas :)"
    }
    else {
        $TestConn = Write-Output "No Christmas for me until I am Back Online :)"
    } 
 
    $dataObject = $ScriptContext.CreateFromObject($OneItemInstance,"Id=Id,HealthState=HealthState,DisplayName=DisplayName",$null)
    $dataObject["Uptime"] = $Uptime
    $dataObject["Xmas"] = $TestConn
    $ScriptContext.ReturnCollection.Add($dataObject)
} 

With this procedure we can do all that PowerShell offers, and this is almost everything 🙂 The drawback I see here is that Script runs under Context of “Console User” so if we delegate it to team with inadequate permissions we might not get result we wanted.

SCOM Dashboards are great. With a little imagination we can do fascinating things. But even here there are some problems we might encounter. First is SCOM console is quite sloooow. And the limit of Supported Connected consoles is 50. This can be sometimes too little.

There are numerous product which we can use to overcome this limitations. One of them I find useful is Live Maps Unity, which among other things offers great SCOM dashboards. I agree with Bob Cornelissen which stated: “As far as dashboarding for SCOM goes, the Live Maps are by far the best product I have seen.”

So why not making even more fun with SCOM dashboards. If you want to have more fun with dashboards you can check it here.

C U Soon

Jure

Advertisements
This entry was posted in Dashboards, Operations Manager, PowerShell, Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s