Answered by:
Get subscription criteria in text with Powershell?

Question
-
Hi Folks,
I was wondering whether it's possible to retreive the criteria for the subscription *as it shows* in the GUI. When I get it with Powershell it's output is (understandably) in XML.
$subs = get-scomnotificationsubscription -DisplayName "Name" $criteria = $subs.Configuration.Criteria $criteria
Output:
<SimpleExpression xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ValueExpression> <Property>RuleId</Property> </ValueExpression> <Operator>Equal</Operator> <ValueExpression> <Value>545b1fdf-45fb-d7aa-120b-234f0d6d866a</Value> </ValueExpression> </SimpleExpression>
Which you can imagine is not-so-friendly to read and interpret.
While the way it looks in the GUI is:
"Notify on all alerts
Raised by xxxx rules/monitors
"
So basically my question is can I show the GUI criteria as it is (plain text)?
Appreciate any inputs on this.
Thanks in advance!
Cheers
Sam (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" wherever applicable. Thanks!) Blog:AnalyticOps Insights Twitter:Sameer Mhaisekar
- Edited by Sameer Mhaisekar Friday, August 3, 2018 11:53 AM
Friday, August 3, 2018 11:52 AM
Answers
-
Hello Sam,
Please have a look on below articles, might help you:
https://opsmgr2k7.wordpress.com/2013/04/30/export-scom-2012-subscriptions-subscribers-and-channels/
https://social.technet.microsoft.com/Forums/systemcenter/en-US/28d9595a-6de3-4a12-a0fa-b794f60a5a48/scom-how-to-get-a-report-or-file-with-all-subscription-criteria?forum=operationsmanagerreporting
http://www.systemcentercentral.com/download/searching-notification-subscription-criteria/
(Please "Mark as Answer/Vote as Helpful" if applicable)
- Marked as answer by Sameer Mhaisekar Monday, August 6, 2018 1:27 PM
Monday, August 6, 2018 8:26 AM
All replies
-
Hi,
This is the original data stored in the database. To get the human-readable result, we may need to parse the .xml format with some more complex script. It seems no existing PowerShell cmdet can achieve this.
import-module operationsmanager
get-scomnotificationsubscription | format-list DisplayName,@{Label="Criteria";Expression={$_.configuration.Criteria}}
PS result:
Hope the above information helps.
-----------------------------------------------
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
- Edited by AlexZhu_775Microsoft contingent staff Monday, August 6, 2018 1:14 AM
- Proposed as answer by AlexZhu_775Microsoft contingent staff Thursday, September 6, 2018 4:57 AM
Monday, August 6, 2018 12:50 AM -
With refer to your XML output, your subscription criteria as
created by specific rules or monitors with RuleId Equal to 545b1fdf-45fb-d7aa-120b-234f0d6d866a
Next steps is using powershell 'get-scomrule -id XXXXXX' to retrieve the display of the rule.
RogerMonday, August 6, 2018 4:09 AM -
Hi,
Thanks for your inputs.
@Alex:
>>This is the original data stored in the database. To get the human-readable result, we may need to parse the .xml format with some more complex script<<
Yes, I'm aware of it. But I can't seem to find any scripts/articles to try it. Would you happen to have any hints/links? The text in the GUI might also be coming from *somewhere*, maybe somewhere from database? I just want to know where this *somewhere* is and whether it is accessible (read-only will do).
@Roger:
Yeah, I can surely figure out the text in xml I provided above, but
1. I have hundreds of subscriptions and
2. Some criteria are MUCH more complex to read.
That is the reason I am looking for a way to script it to give me the criteria in text, as it gives in the Subscription's summary.
Is this possible?
Thanks for all the help.
Cheers
Sam (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" wherever applicable. Thanks!) Blog:AnalyticOps Insights Twitter:Sameer Mhaisekar
Monday, August 6, 2018 7:47 AM -
Hello Sam,
Please have a look on below articles, might help you:
https://opsmgr2k7.wordpress.com/2013/04/30/export-scom-2012-subscriptions-subscribers-and-channels/
https://social.technet.microsoft.com/Forums/systemcenter/en-US/28d9595a-6de3-4a12-a0fa-b794f60a5a48/scom-how-to-get-a-report-or-file-with-all-subscription-criteria?forum=operationsmanagerreporting
http://www.systemcentercentral.com/download/searching-notification-subscription-criteria/
(Please "Mark as Answer/Vote as Helpful" if applicable)
- Marked as answer by Sameer Mhaisekar Monday, August 6, 2018 1:27 PM
Monday, August 6, 2018 8:26 AM -
Thanks a lot. Although not exactly what I need but the second link gives me a good start. Now I have to see how can I enhance it to do the stuff that I want.
Cheers
Sam (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" wherever applicable. Thanks!) Blog:AnalyticOps Insights Twitter:Sameer Mhaisekar
- Proposed as answer by AlexZhu_775Microsoft contingent staff Thursday, September 6, 2018 4:57 AM
Monday, August 6, 2018 1:29 PM