Searching through Notification Subscription Criteria

While working for a company who uses a LOT of subscriptions, I was asked from time to time what alerts are they receiving or what rule was the source of the alert, or etc.  The alert subscription ID was not always available.  So I came up with a Powershell script to create an HTML page with Notification subscriptions and the criteria in a readable format. My next project is to take leverage searching for key words and only pulling out subscriptions that match the key word text in the criteria.

I freely admit that the code behind this is not my best.  it is actually quite messy but I sat down, hammered it out in one sitting and it worked for what I needed it for.  I thought I would share with the community.

There are 4 lines per subscription (alternating grey/white every 3 lines).  the first line is the subscription and criteria.  The second row is the groups that are used as part of the filtering.  Third row is the classes used for filtering.  For whatever reason, those are not included as part of the criteria so I kept them separate. The fourth and final row is the recipient list and any other channel information used whether SMTP, or a command.  Commands will typically end in a GUID.

I hope to make it look a little nicer and less rudimentary but this is what I have for now.

Below is sample output:

SCOM Notification Summary – 10:44:06 AM

Item Detail
Test Subscription  + ANY of the following must be True.
.     * Rule = % Logical Disk Free Space Windows Server 2012
.     * Monitor = Administrative Status (Fibre Channel MGMT 8888 Port)
– End of ANY.
+ ANY of the following must be True.
.     * Monitored Object = L3-122-AD-01.pero12.net
.     * Monitored Object = L3-122-SCOM-01.pero12.net
.     * Monitored Object = L3-122-SQL12-01.pero12.net
– End of ANY.
+ ANY of the following must be True.
.     * Severity = 0
.     * Severity = 1
.     * Severity = 2
– End of ANY.
+ ANY of the following must be True.
.     * Priority = 0
.     * Priority = 1
.     * Priority = 2
– End of ANY.
* ResolutionState = 0
* AlertName Like %Specific Alert Name%
* AlertDescription Like %Specific Description%
+ ALL of the following must be TRUE.
.     * TimeRaised Less 2014-02-20T18:22:29.1209044Z
.     * TimeRaised Greater 2014-02-18T18:22:29.0000000Z
– End of ALL.
* Owner Like %Specific Owner%
* LastModifiedBy Like %Modified by specific User%
+ ALL of the following must be TRUE.
.     * LastModified Less 2014-02-20T18:25:29.1826233Z
.     * LastModified Greater 2014-02-20T16:25:29.1826233Z
– End of ALL.
+ ALL of the following must be TRUE.
.     * TimeResolutionStateLastModifiedInDB Less 2014-02-20T18:25:29.1826233Z
.     * TimeResolutionStateLastModifiedInDB Greater 2014-02-20T16:25:29.1826233Z
– End of ALL.
+ ALL of the following must be TRUE.
.     * TimeResolved Less 2014-02-20T18:25:29.1826233Z
.     * TimeResolved Greater 2014-02-20T16:25:29.1826233Z
– End of ALL.
* ResolvedBy Like %specific user resolved%
* TicketId Like %ticket ID%
+ ALL of the following must be TRUE.
.     * TimeAdded Less 2014-02-20T18:25:29.1826233Z
.     * TimeAdded Greater 2014-02-20T14:25:29.1826233Z
– End of ALL.
* SiteName Like %specific Site%
* CustomField1 Like %value for custom field 1%
* TfsWorkItemId Like %TFS work Item ID%
* TfsWorkItemOwner Like %TFS work item owner%
Groups
CLASSES Windows Computer
RECIPIENT List my alias 

myalias (Smtp)  myAlias@domain.net