Did you know that you can query the ORF statistics counters from the Windows PowerShell? This is how it works for the cumulative On Arrival “Tested Emails” counter:
$ORF = New-Object -com “orfeesvc.EnterpriseService”
$cumulative = “”$sincestartup = “”
$ORF.GetStatisticsEx([ref] $cumulative, [ref] $sincestartup)
$xmldoc = New-Object -com “MSXML.DomDocument”
$xmldoc.loadXML($cumulative)
$node = $xmldoc.selectSingleNode(“/statistics/onarrival/tested”)
$oatested = $node.nodeTypedValue
That’s because PowerShell can invoke COM objects and what ORF returns via the GetStatisticsEx() method is really just XML that can be loaded into the COM-based MSXML parser, and so on…
I first came across the powershell when I installed Exchange2007, but I did not know what it was.
It is like the old cmd.exe shell but modernised for dealing this .NET executeables natively.
You can download an install for XP, Vista etc. It will ship with windows server 2008.
see http://msdn2.microsoft.com/en-us/library/ms714658.aspx for how it works.
I’ve heard about PowerShell (that time Monad) before Exchange 2007 and liked it from the beginning. The trick with PowerShell is that *everything* is an object in the shell. For instance, when you query the list of services (“get-service”), you get a list of service objects (System.ServiceProcess.ServiceController objects) that have methods and properties. For instance, you can start the ORF Service using “(Get-Service vsorfee).Start()”. Sure, “net start” does it pretty well, but if you check the properties and methods (“Get-Service vsorfee | get-member”) you’ll see that you can do a lot more than just starting or stopping a service–modify startup type, description, etc. And as everything is an object, you can do things like get-service | format-table ServiceName, Status, ServiceType, without the get-service cmdlet supporting any type of formatting.
Check out http://en.wikipedia.org/wiki/Windows_PowerShell for more examples.