Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

getting all critical & high priority alerts from ruls

16 views
Skip to first unread message

Kobile

unread,
May 23, 2009, 4:15:01 AM5/23/09
to
Hi all,

i having truble to get all rules that generate an alert with sevirity
critical and high priority.

is it posible to export a list with powershell ?

Stefan Koell

unread,
May 25, 2009, 7:27:59 AM5/25/09
to
Here are the 2 functions I use. You need to set the $RMS variable to the
name of your root management server.

I hope this helps.

cheers
Stefan
http://www.code4ward.net
Home of Royal TS - the best Remote Desktop Client

##
############################################################################
## Get-RulesMatchingPriority
## Dumps all rules (from all MPs) with alert creation write action matching
## the specified alert priority (0 = Low, 1 = Medium, 2 = High)
##
## -Priority 0, 1 or 2
##
############################################################################
function Get-RulesMatchingPriority {
param ([int] $Priority)

## connect to management group
$ManagementGroup = New-Object
Microsoft.EnterpriseManagement.ManagementGroup($RMS)

$ManagementPacks = $ManagementGroup.GetManagementPacks()
foreach ($ManagementPack in $ManagementPacks)
{
$Rules = $ManagementPack.GetRules()
foreach ($Rule in $Rules)
{
if ($Rule.Enabled -ne "false")
{
foreach ($WriteAction in $Rule.WriteActionCollection)
{
if ($WriteAction.Name -like "*Alert*")
{
if ($WriteAction.Configuration -like
"*<Priority>$Priority</Priority>*")
{
Write-Host "Rule : "$ManagementPack.Name" :
"$Rule.DisplayName
}
}
}
}
}
}
}

##
############################################################################
## Get-MonitorsMatchingPriority
## Dumps all monitors (from all MPs) with alert creation write action
matching
## the specified alert priority (Low, Medium or High)
##
## -Priority 0, 1 or 2
##
############################################################################
function Get-MonitorsMatchingPriority {
param ([string] $Priority)

$ManagementGroup = New-Object
Microsoft.EnterpriseManagement.ManagementGroup($RMS)

$ManagementPacks = $ManagementGroup.GetManagementPacks()
foreach ($ManagementPack in $ManagementPacks)
{
$Monitors = $ManagementPack.GetMonitors()
foreach ($Monitor in $Monitors)
{
if ($Monitor.Enabled -ne "false")
{
$AlertSetting = $Monitor.AlertSettings
if (!($AlertSetting -eq $null))
{
if ($AlertSetting.AlertPriority -eq $Priority)
{
write-Host "Monitor : "$ManagementPack.Name" :
"$Monitor.DisplayName
}
}
}
}
}
}

"Kobile" <Kob...@discussions.microsoft.com> wrote in message
news:038348C3-F3EB-4B14...@microsoft.com...

Kobile

unread,
May 27, 2009, 4:32:02 AM5/27/09
to
Hi Stefan,

Thanks a lot. you helped me a lot .

ScottieH

unread,
Jun 26, 2009, 4:11:01 PM6/26/09
to

Stefan,
Please excuse my ignorance with powershell, but where exactly to I assign
the RMS variable and what is the syntax? Could you please provide an
example?
Thansk

Kobile

unread,
Jun 27, 2009, 2:04:01 PM6/27/09
to

Hi ScottieH,

i changed Stefan Functgion to a powershell script , the following is for
getting all rules to a TXT file.

1. copy the script to a PS1 file

############################################################################
## Get-RulesMatchingPriority
## Dumps all rules (from all MPs) with alert creation write action matching
## the specified alert priority (0 = Low, 1 = Medium, 2 = High)
##
## -Priority 0, 1 or 2
##
############################################################################

param ($RMS, [int] $Priority)

## connect to management group
$ManagementGroup = New-Object
Microsoft.EnterpriseManagement.ManagementGroup($RMS)

$ManagementPacks = $ManagementGroup.GetManagementPacks()
foreach ($ManagementPack in $ManagementPacks)
{
$Rules = $ManagementPack.GetRules()
foreach ($Rule in $Rules)
{
if ($Rule.Enabled -ne "false")
{
foreach ($WriteAction in $Rule.WriteActionCollection)
{
if ($WriteAction.Name -like "*Alert*")
{
if ($WriteAction.Configuration -like
"*<Priority>$Priority</Priority>*")
{

$ManagementPack.Name + "," + $Rule.DisplayName
}
}
}
}
}
}
############################################################################

2. open the scom powershell .
goto start -> programs -> system center operations manager 2007 -> command
shell


3. run the ps1 script as follow:
myscript.ps1 RMSserverName PrioriyNumber > Rules.txt

4. the script contain this line "param ($RMS, [int] $Priority)"
$RMS - argument for RMSserverName
$Priority - argument for priority number.

Hope this will help you,

Kobile

ScottieH

unread,
Jun 30, 2009, 2:31:01 PM6/30/09
to

Doesn't quite work for me. Getting the following results when trying to run
the script:

>highprirules.ps1 shr-sv8004 2 > hprules.txt

Cannot open file because the current provider
(Microsoft.EnterpriseManagement.Ope
rationsManager.Client\OperationsManagerMonitoring) cannot open a file.
At line:1 char:32
+ highprirules.ps1 shr-sv8004 2 > <<<< hprules.txt

PS Monitoring:\SHR%002dSV8004.na01.crl.com

0 new messages