How to: Managing Exchange 2000/2003 using PowerShell - Part II
| Published date | Fri, 2007-08-24 11:44 |
| Category | |
| Author | Nicolas Blank |
| Printable Version | Email this Article | |
|
|
|
| Post to del.icio.us | Furl it | Spurl it | |
|
|
|
If you haven't read the Part I of this article series, please visit here
Introduction
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 few PoweShell 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
..:
..:
..:
Summary
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?
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.
Discuss/Post to digWin

About Nicolas Blank
Nicolas Blank - Operations Director, Credo Technical Services
Nicolas Blank is a Microsoft Infrastructure Architect and Operations Director for Credo Technical Services in South Africa and specializes in Exchange, Active Directory, architecture, systems management, migration and scripting. Nicolas is a Microsoft MVP for Exchange and spends what spare time he has writing, blogging and talking about Exchange and associated technologies. www.credotech.co.za
Recent Articles by the author
Featured Links
-
VirtualServerTalk.com: Fresh look at virtualization community.
Get all tips, guides, reviews you need to know today. -
WorkStationTalk.com: Gateway to Imaging & Maintenance of your WorkStation.




