Working with the SCOM Powershell Module

Working with SCOM in the console and working with the SCOM Powershell module are two vastly different things. Powershell is much quicker, especially for getting lots of data and related objects at once. However, if you haven’t worked very much with the Operations Manager Powershell Module very much, these might be a few quirks or cool tips you should know.

Lets start by getting management packs in SCOM.

$mp = get-scommanagementpack -DisplayName "*windows*" | where {$_.sealed -eq $true}

scom powershell module

As you can see get-scommanagment pack accepts wildcards, this should return back quite a few MPs if you are monitoring Windows. Also note when using pipe Where it wants an -eq to match true/false. More on why that is important in a minute.

There are many properties available when you get SCOM objects, a few of the properties available for Management Packs are Name and DisplayName.

scom powershell module

Now, let’s say we wanted to get all monitors that are enabled from these Management Packs. We’ll use the Get-SCOMMonitor command.

get-scommonitor -ManagementPack $mp | where{$_.Enabled -match $true}

scom powershell module

So get-scommonitor accepts multiple management packs, however to get enabled monitors you need to use -match instead of -eq. If you use -eq you’ll get nothing back. This can be slightly frustrating if you are expecting some consistency.

Next let’s get a SCOM Group by using Get-SCOMGroup command.

$grp = get-scomgroup -ComputerName $scom -Credential $cred -DisplayName "wa*"

scom powershell module

Notice here, I’ve used -computername This is getting the group to remotely to my SCOM management server. I’ve found more SCOM commands that accept the -computername parameter than don’t.

Next if you do $grp.name it returns nothing. Unlike the Management Packs from above, that we got earlier, the full name of the object is not .name its .fullname. See below

scom powershell module

And finally my favorite part of SCOM Powershell is .GetRelatedMonitoringObjects() This returns all the related monitoring objects of the item you performed it on. In this case it gets all the members of the group.

scom powershell module

This works on many SCOM Classes, but not all. So try it out and see what you can do.

So, in conclusion, we have:

  • Many SCOM commands can take wildcards
  • You can get multiple monitors from multiple management packs at the same time
  • Some commands require -eq and some require -match
  • some SCOM Classes have a Name Property whereas others have FullName
  • many SCOM Commands can be run remotely, provided you have the SCOM Module installed.
  • use .GetRelatedMonitoringObjects() to find child objects of groups or other classes.

2 thoughts on “Working with the SCOM Powershell Module”

  1. I use this one often to get open alerts of a similar name, usually helps with cleanup after deploying a new management pack:

    get-scomalert -ResolutionState 0 | Select NetbiosComputerName, MonitoringObjectDisplayName | Where {$_.MonitoringObjectDisplayName -like "*something*"} | Sort MonitoringObjectDisplayName

Comments are closed.