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