Monthly Archives: October 2015

Powershell Grid Widget with Filter

The Powershell Grid Widget introduced since UR2 for System Center 2012 R2 Operations Manager opens wide open the possibilities of what can be covered by Operations Manager Dashboards.

I was very excited by this particular widget and I started using it. If the same applies to you, then perhaps it was not long before you noticed a short-coming of its implementation that frustrates in case of relative large output data provided by the Powershell data source (the script).
In such situations, a Filter control (like for instance the one that is part of the State widget) would be much appreciated.

I was not able to find such solution (not for lack of trying) therefore I decided to create one myself and the end result was the library MP that I uploaded to TechNet Gallery (https://gallery.technet.microsoft.com/Powershell-Grid-Widget-919dc3d6).

This library management pack adds the PowerShell Grid Widget (Filtered) that allows the user now to create PowerShell Grid dashboards, using the template driven wizard. The usage and configuration of the new widget is the same as the Powershell Grid Widget, just that the output is now searchable (can be filtered). Cool!

post5-1

Just import the Management Pack and start using the new widget in your dashboard visualizations.

I am providing below an example of the usage.

I often felt a need to perform fast, yet organized, searches against SCOM. Here is what I want to ask SCOM from my dashboard: start by telling me all the classes that you’re aware, let me select one class (or even maybe several classes) then tell me the instances of that class that you have discovered.
Then let me search for an instance and when I select it, let me know the details of the instance, the health and all alerts related.

Steps to create such dashboard:

1. Create a Grid Layout dashboard with 5 Cells, name it “Bing SCOM”, for fun…

2. Add the first widget using “Powershell Grid Widget (Filtered)”, name it Search Class, and enter the following script:


$classes = Get-SCOMClass

foreach ($class in $classes)
{
	$dataObject = $ScriptContext.CreateInstance("xsd://foo!bar/baz")
	$dataObject["Id"]=$class.Id.ToString()
	$dataObject["Name"]=$class.Name
	$dataObject["DisplayName"]=$class.DisplayName
	$ScriptContext.ReturnCollection.Add($dataObject)
}

3. Add the second widget using “Powershell Grid Widget (Filtered)”, name it Search Instance, and enter the following script:


Param($globalSelectedItems)

foreach ($globalSelectedItem in $globalSelectedItems)
{
	$class = Get-SCOMClass -Id $globalSelectedItem["Id"]
	$instances = Get-SCOMClassInstance -class $class
	foreach ($instance in $instances)
	{
		$dataObject = $ScriptContext.CreateFromObject($instance, "Id=Id,State=HealthState,DisplayName=DisplayName,Path=Path", $null)
		$dataObject["ParentRelatedObject"] = $class.DisplayName
		$ScriptContext.ReturnCollection.Add($dataObject)
	}
}

4. Add the third widget using Details Widget.

5. Add the fourth widget using the Contextual Health Widget.

6. Add the fifth widget using the Contextual Alert Widget.

Here is a screenshot of the end result.

post5-2

Enjoy your SCOM searches now!

Advertisements