Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

       How did you like this article? Please vote and let us know.          

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Shannal L. Thomas
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath

 

 
 

Managing Exchange 2000/2003 using PowerShell - Part 2

Page 1

Managing Exchange 2000/2003 using PowerShell part 2

Managing Exchange 2000/2003 using PowerShell - Part 1
Managing Exchange 2000/2003 using PowerShell - Part 3

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. PowerShell 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 PowerShell can do I'm going to contrast a few PowerShell one-liners 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 Exchange 2003. In my next post, I'll be writing more on what else we can do with WMI and other things in Exchange 2000?

If you liked this article and would like to see more about PowerShell and Exchange, then check out BlankMan's blog (that's me) on http://blankmanblog.spaces.live.com/. Please also leave me a comment on what you do and don't like.

Managing Exchange 2000/2003 using PowerShell - Part 1
Managing Exchange 2000/2003 using PowerShell - Part 3

Managing Exchange 2000/2003 using PowerShell - Part 2

Nicolas Blank Page 1


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Pro Exchange. OutlookExchange.Com and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

© Copyright Pro Exchange, Inc., 2006