Thursday, September 14, 2006

Get a Quick Status of IMF perf counters with Powershell (Exchange 2003)

Sometimes a quick way to check how effective your IMF gateway SCL configuration is s to look at the IMF performance counters which tell you how many messages are being assigned certain SCL levels. This can also give you a little insight into how all those spammers are going about trying to crack the algorithms the IMF uses to determine the SCL of a message. To show the perfmon counters for IMF with powershell you can use the Win32_PerfRawData_MSExchangeUCF_MSExchangeIntelligentMessageFilter WMI class via the get-wmiobject cmdlet. The following is a very simple script that shows formatted in a table the number of message that have been received and assigned a specific SCL as well as the total number of message processed by the IMF and the total number that the Gateway action has been performed on. To run the script it takes on command line parameter which is the name of the server you wish to run it against eg

C:\imfperf.ps1 servername

I’ve put a downloadable copy of the code here the code itself looks like



param([String] $servername = $(throw "Please specify the Servername"))
$WmiNamespace = "ROOT\CIMV2"
$filter = "Name='_total'"
$Qresults = get-wmiobject -class Win32_PerfRawData_MSExchangeUCF_MSExchangeIntelligentMessageFilter -Namespace $WmiNamespace -ComputerName $servername -filter $filter
$format = @{Expression = {$_.TotalMessagesAssignedanSCLRatingof0};Label = "0"},@{Expression = {$_.TotalMessagesAssignedanSCLRatingof1};Label = "1"},@{Expression = {$_.TotalMessagesAssignedanSCLRatingof2};Label = "2"},
@{Expression = {$_.TotalMessagesAssignedanSCLRatingof3};Label = "3"},@{Expression = {$_.TotalMessagesAssignedanSCLRatingof4};Label = "4"},@{Expression = {$_.TotalMessagesAssignedanSCLRatingof5};Label = "5"},
@{Expression = {$_.TotalMessagesAssignedanSCLRatingof6};Label = "6"},@{Expression = {$_.TotalMessagesAssignedanSCLRatingof7};Label = "7"},@{Expression = {$_.TotalMessagesAssignedanSCLRatingof8};Label = "8"},
@{Expression = {$_.TotalMessagesAssignedanSCLRatingof9};Label = "9"},@{Expression = {$_.TotalUCEMessagesActedUpon};Label = "#Gate-Blk"},@{Expression = {$_.TotalMessagesScannedforUCE};Label = "Total"}
$Qresults | format-table $format

2 comments:

Anonymous said...

Hi,

I seem to get an error when executing your script that says that the class is invalid or does not exist. I listed all WMI objects and cannot find it on my E2k7 EDGE server. Any idea why ? Thanks for putting your script up and shraing your knowledge and experiments. It is just too bad I cannot make it work. Do you know a way of listing performance counters for message rejections, accepted messages, etc etc etc from an Excahnge Shell Session ?

Thanks again,

C.

Glen said...

This code wont work on Exchange 2007 because the paths to the performance counters have been renamed. One method you can use is to parse the content agent logs maybe have a look at http://gsexdev.blogspot.com/2007/10/exchange-2007-content-agent-log-message.html

Cheers
Glen