This one is a modification of what you can find here. The main difference is we can select specific Management Packs with this script. Replace the parameters with your criteria. To find management pack system name, you can run get-managementpack | select name | sort name.
function GetThreshold ([String] $configuration)
{
$config = [xml] ("<config>" + $configuration + "</config>")
$threshold = $config.Config.Threshold
if($threshold -eq $null)
{
$threshold = $config.Config.MemoryThreshold
}
if($threshold -eq $null)
{
$threshold = $config.Config.CPUPercentageThreshold
}
if($threshold -eq $null)
{
if($config.Config.Threshold1 -ne $null -and $config.Config.Threshold2 -ne $null)
{
$threshold = "first threshold is: " + $config.Config.Threshold1 + " second threshold is: " + $config.Config.Threshold2
}
}
if($threshold -eq $null)
{
if($config.Config.ThresholdWarnSec -ne $null -and $config.Config.ThresholdErrorSec -ne $null)
{
$threshold = "warning threshold is: " + $config.Config.ThresholdWarnSec + " error threshold is: " + $config.Config.ThresholdErrorSec
}
}
if($threshold -eq $null)
{
if($config.Config.LearningAndBaseliningSettings -ne $null)
{
$threshold = "no threshold (baseline monitor)"
}
}
return $threshold
}
$perfMonitors = get-managementpack -name '[Management Pack System Name]' | get-monitor | where {$_.XmlTag -eq 'UnitMonitor'}
$perfMonitors | select-object @{name="Target";expression={foreach-object {(Get-MonitoringClass -Id:$_.Target.Id).DisplayName}}},DisplayName, @{name="Threshold";expression={foreach-object {GetThreshold $_.Configuration}}}, @{name="AlertOnState";expression={foreach-object {$_.AlertSettings.AlertOnState}}}, @{name="AutoResolveAlert";expression={foreach-object {$_.AlertSettings.AutoResolve}}}, @{name="AlertSeverity";expression={foreach-object {$_.AlertSettings.AlertSeverity}}} | sort Target, DisplayName | export-csv "[path\file.csv]"
Try this:
function GetThreshold ([String] $configuration)
{
$config = [xml] ("<config>" + $configuration + "</config>")
$threshold = $config.Config.Threshold
if($threshold -eq $null)
{
$threshold = $config.Config.MemoryThreshold
}
if($threshold -eq $null)
{
$threshold = $config.Config.CPUPercentageThreshold
}
if($threshold -eq $null)
{
if($config.Config.Threshold1 -ne $null -and $config.Config.Threshold2 -ne $null)
{
$threshold = "first threshold is: " + $config.Config.Threshold1 + " second threshold is: " + $config.Config.Threshold2
}
}
if($threshold -eq $null)
{
if($config.Config.ThresholdWarnSec -ne $null -and $config.Config.ThresholdErrorSec -ne $null)
{
$threshold = "warning threshold is: " + $config.Config.ThresholdWarnSec + " error threshold is: " + $config.Config.ThresholdErrorSec
}
}
if($threshold -eq $null)
{
if($config.Config.LearningAndBaseliningSettings -ne $null)
{
$threshold = "no threshold (baseline monitor)"
}
}
return $threshold
}
$perfMonitors = get-managementpack -name 'Microsoft.Windows.Server.AD.2008.Monitoring' | get-monitor | where {$_.XmlTag -eq 'UnitMonitor'}
$perfMonitors | select-object @{name="Target";expression={foreach-object {(Get-MonitoringClass -Id:$_.Target.Id).DisplayName}}},DisplayName, @{name="Threshold";expression={foreach-object {GetThreshold $_.Configuration}}}, @{name="AlertOnState";expression={foreach-object {$_.AlertSettings.AlertOnState}}}, @{name="AutoResolveAlert";expression={foreach-object {$_.AlertSettings.AutoResolve}}}, @{name="AlertSeverity";expression={foreach-object {$_.AlertSettings.AlertSeverity}}} | sort Target, DisplayName | export-csv "C:Microsoft.Windows.Server.AD.2003.Monitoring.csv"
MPViewer doesn't show performance threshold information, whereas the script here does. I don't have a version for rules – this is just an example.
Hi Jonathan,
With the help of MP Viewer i am unable to get the monitors and rules for exchange 2010 MP. Could you please help me on this.
I think that's unusual. Shouldn't take more than a couple minutes at the most. Something is not right.
Hello,
If I try the "same" powershell command from the PS Command prompt i do not get an error but the exported file is still empty…
>get-managementpack -path [.] -name 'Microsoft.Windows.Server.AD.2008.Monitoring' |
get-monitor | where {$_.XmlTag -eq 'UnitMonitor'} | select-object @{name="Target";ex
pression={foreach-object {(Get-MonitoringClass -Id:$_.Target.Id).DisplayName}}},Disp
layName, @{name="Threshold";expression={foreach-object {GetThreshold $_.Configuratio
n}}}, @{name="AlertOnState";expression={foreach-object {$_.AlertSettings.AlertOnStat
e}}}, @{name="AutoResolveAlert";expression={foreach-object {$_.AlertSettings.AutoRes
olve}}}, @{name="AlertSeverity";expression={foreach-object {$_.AlertSettings.AlertSe
verity}}} | sort Target, DisplayName | export-csv "C:Microsoft.Windows.Server.AD.20
03.Monitoring.csv"
PS C:usersdominiqueddocuments
>
Thanks,
Dom
Hello,
1 hour that the ps is running is it usual?
Thanks,
Dom
Hello Jonathan,
This is working fine.
Do you have the same one for rules?
Thanks,
Dom
Hello Jonathan,
How would you compare advantages and disadvantages to use powershell script (like the one in this blog) or mpviewer?
Thanks,
Dom