Doing more WMI stuff with PowerShell and "old" Exchange versions

 

I'm going to start off with by referring to an Exchange 2000 article called Automating Exchange 2000 Management with Windows Script Host, since it set's the scene quite nicely for WMI based management for Exchange 2000. Exchange 2000 introduced a set of new WMI classes, and Exchange 2003 introduced a few more. PoweShell is renowned as an Exchange 2007 tool, however here were going to learn to use it to manage just about anything that has a MWI provider, with Exchange 2000/3 as my focus for today.

To show off what PoweShell can do I'm going to contrast a PoweShell one-liner with the equivalent scripts taken from the Exchange 2000 article mentioned above.

get-wmiobject ExchangeServerState -Namespace "root\cimv2\applications\exchange" -ComputerName 2000server

HERE IS SOME SAMPLE vbscript TO DO THE SAME THING:

Sample 1 Using the ExchangeServerState WMI class

   1:' VBScript script listing all ExchangeServerState names and properties      
   2:' available with the WMI Exchange 2000 provider.
   .:
   9:Option Explicit
  10:
  11:Const cComputerName = "LocalHost"
  12:Const cWMINameSpace = "root/cimv2/applications/exchange"
  13:Const cWMIInstance  = "ExchangeServerState"
  ..:
  ..:
  24:Set ExchangeServerList = _
                  GetObject("winmgmts:{impersonationLevel=impersonate}!//" &
  25:                       cComputerName & "/" & _
  26:                       cWMINameSpace).InstancesOf(cWMIInstance)
  27:
  28:For each ExchangeServer in ExchangeServerList
  29:    WScript.Echo "---------------------------------------------"
  30:    WScript.Echo "Name: " & ExchangeServer.Name
  31:    WScript.Echo "DN: " & ExchangeServer.Dn
  32:    WScript.Echo "GUID: " & ExchangeServer.Guid
  33:    WScript.Echo "Version: " & ExchangeServer.Version
  34:    WScript.Echo "GroupDN: " & ExchangeServer.GroupDN
  35:    WScript.Echo "Unreachable: " & ExchangeServer.Unreachable
  36:
  37:    WScript.Echo "ServerMaintenance: " & ExchangeServer.ServerMaintenance
  38:
  39:    WScript.Echo "ServerStateString: " & ExchangeServer.ServerStateString
  40:    WScript.Echo "ServerState: " & ExchangeServer.ServerState
  41:
  42:    WScript.Echo "QueuesStateString: " & ExchangeServer.QueuesStateString
  43:    WScript.Echo "QueuesState: " & ExchangeServer.QueuesState
  44:
  45:    WScript.Echo "DisksStateString: " & ExchangeServer.DisksStateString
  46:    WScript.Echo "DisksState: " & ExchangeServer.DisksState
  47:
  48:    WScript.Echo "MemoryStateString: " & ExchangeServer.MemoryStateString
  49:    WScript.Echo "MemoryState: " & ExchangeServer.MemoryState
  50:
  51:    WScript.Echo "CPUStateString: " & ExchangeServer.CPUStateString
  52:    WScript.Echo "CPUState: " & ExchangeServer.CPUState
  53:
  54:    WScript.Echo "ClusterStateString: " & _
                      ExchangeServer.ClusterStateString
  55:    WScript.Echo "ClusterState: " & ExchangeServer.ClusterState
  56:
  57:    WScript.Echo "ServicesStateString: " & _
                      ExchangeServer.ServicesStateString
  58:    WScript.Echo "ServicesState: " & ExchangeServer.ServicesState
  59:Next
  ..:
  ..:
  ..:

My PowerShell script connects to a machine called "2000Server". The VBScript sample connect to localhost. Adjust the names to suit your environment and run both.  PowerShell has the advantage of auto rendering the object and displaying the objects properties when it returns. In VBScript, we need to know the objects properties in order to display them. I hope you're seeing that PowerShell is a pretty cool tool when it comes to Exchange 2000 and Excahnge 2003. In my next post, I'll be writing more on what else we can do with WMI and other things in Exchange 2000?