Visualising SCOM PowerShell tasks with SquaredUp

September 24, 2019

Visualising SCOM PowerShell tasks with SquaredUp

In this blog we are going to discuss how you can use Cookdown’s PowerShell MP to create SCOM tasks written in PowerShell and how you can visualise the output of your tasks in a much more efficient and user-readable format – using SquaredUp.

 

Visualising SCOM PowerShell tasks with SquaredUp

 

SCOM tasks are fantastic – they let you access data on demand. You can run them remotely in response to an alert and use them to get detailed diagnostics, or to run recoveries, etc. There are console tasks which run on the Management Servers, and there are agent tasks which you can run on the agents of your choice.

The Powershell Management Pack

This management pack gives you the ability to run PowerShell scripts in your tasks – which makes your life much easier. You may already have a few PowerShell scripts floating around that your respective teams use to diagnose an issue or recover from one, but you probably also faced issues automating them because SCOM refused to work with PowerShell. Now that you’ve got this MP in your arsenal, you can automate your PowerShell scripts using SCOM.

To get started, check out this  excellent walk-through of the MP.

The Management Pack is very helpful in itself, but you can take it even further. The MP solves the first issue of not being able to run PowerShell scripts, but now, you need to find a way to incorporate that into your dashboarding so you can share the results with other teams as well. While I have with me a PowerShell script that fetches the recent updates installed on the server and displays the result in CSV format, how can I visualise my task results and share them with my colleagues? Why, using Squared Up of course!

Here we will walk you through the process of how to achieve this end-to-end using the PowerShell MP and Squared Up’s SCOM task tile.

 

How to incorporate SCOM PowerShell tasks into SquaredUp

 

  1. Prepare the PowerShell script. The script I have is actually a part of SquaredUp’s Data On Demand Management Pack, which has many useful PowerShell tasks in it. For now, the script I’m using can be found here:

https://github.com/squaredup/Community.DataOnDemand.MP/blob/master/ManagementPacks/Community.DataOnDemand/Scripts/Get-WindowsUpdateHistory.ps1

 

  1. Now, I’m going to create a SCOM task using the Powershell script I have. I’ve imported Cookdown’s Powershell MP already. And as you can see, I’ve now got an option to run Powershell scripts, which I didn’t have before.

 

Importing Cookdown's PowerShell management pack gives the option to run PowerShell scripts in SCOM

 

  1. Give it a name, and the target class you want to run it against. I’m calling it “List Update History (Data On Demand)” and scope it to Windows Computers. Click next, and you should get a screen where you can paste your script. Bear in mind that this is a regular plain text editor – we recommend that you only paste your final version of the script into this box, as it can be a pain to modify it from here.

 

How to create a SCOM task using the PowerShell script

 

Paste your script and hit the create button. Now as you go into the view scoped to the class you targeted your task to, it should be visible on the right-hand side under “Windows Computer Tasks.”

 

How to create a SCOM task using PowerShell scripts and Cookdown's PowerShell MP 

  1. Alright, all set. Now as I run this task, I get the following output:

 

How SquaredUp can help with data visualisation in SCOM

 

Hmm…looks really useful, but it isn’t very pretty to look at! Let’s see how SquaredUp can help me visualise it better.

Also, it looks like I have to repeat this process every time on each server I want to run the task on. Would be great if I could just create it once and see the results every time I’m browsing into the object automatically.

 

  1. Jumping into SquaredUp, I notice that if I go onto the create a “Perspective” view, I should be able to see the results every time I browse into the server. Let’s try creating a “Perspective”. Browse into one of the objects of the class you want to target this task on and click on the “New Perspective” button on the top.

 

Creating a "New Perspective" in SquaredUp

 

I’m presented with the below screen:

 

How to create a "Perspective" in SquaredUp for visualising output 

  1. The “SCOM Task” tile looks like something I want!

 

The "SCOM Task" tile

 

Fill in the fields, such as the Perspective Name, the target, name for your tile, etc.

The On-Demand Task (Raw) is for the tasks that return data in text format, while the (Grid) option is for the tasks that return results in tabular/structured format like CSV, json, etc.

Let’s select On-Demand Task (Grid) for our purposes.

 

SquaredUp's On-Demand Task (Grid)

 

Scope it properly to “this object” so that every time you browse into a server you see the task appearing there.

 

SquaredUp "List Update History (Data on Demand)

 

Under “task config” I can see all the tasks available to me. The one we’re looking for is “List Update History (Data On Demand)”.

You can also specify some overrides from the list, I will select the “ShowTop” override and narrow down the list to 10. Once done, hit “apply changes” and then “next”.

 

Specify overrides in SquaredUp such as the "ShowTop" override

 

Under “task return format” you have options to choose which format you want to display the data in. I will select “CSV” as that is the best format to display my data as seen from the preview below.

 

Select "CSV" under "task return format" when deciding which format you want to display the data in in SquaredUp

Perfect! Looks nice and tidy. Now one last thing to check is whether this perspective does indeed appear on all the servers like I intended. Let’s select a different server and see if that works.

Browsing into a different server (xxx.xxx.AUTO2):

 

Check whether this perspective appears on all the servers in SquaredUp by browsing into a different server

 

And indeed! I can see it now on all the servers. Mission accomplished!

As you can imagine, the use cases of this are only limited by the number of scripts you can write (read: infinite). You can also obviously have more than one tile in there, and so see results of more than one tasks on the same page.

Hope this gives you ideas on how you can visualise your SCOM task results with SquaredUp and use your PowerShell scripts and SCOM tasks to the fullest!

 

© Squared Up Ltd. 2019

Squared Up is a registered trademark of Squared Up Ltd. All other trademarks are the property of their respective owners. Privacy policy | Terms and Conditions