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 ?
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...
Thanks a lot. you helped me a lot .
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
>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