Daily IT Matters, this is the place where I post my daily findings on IT.

Friday, September 29, 2006

Managing Exchange 2003 with WMI, Part 1

Like most Windows products released in 2003, Exchange Server 2003 offers more manageability through Windows Management Instrumentation (WMI). As Table 1 (http://www.winnetmag.com/microsoftexchangeoutlook, InstantDoc ID 40755) shows, Exchange 2000 Server was the first release in which Microsoft implemented WMI interfaces for Exchange. The original release offered three WMI providers: ExchangeRoutingTableProvider, ExchangeQueueProvider, and ExchangeClusterProvider. These providers are available from the Root\CIMV2\Applications\Exchange namespace. Later, Microsoft released Exchange 2000 Service Pack 2 (SP2), which introduced two new WMI providers in the Root\MicrosoftExchangeV2 namespace: ExchangeDsAccessProvider and ExchangeMessageTrackingProvider.

Little difference exists between the five providers in Exchange 2000 SP2 and those same five providers in Exchange 2003. The only noticeable change is that Microsoft updated the ExchangeMessageTrackingProvider's Exchange_MessageTrackingEntry class by adding values to the class's EntryType property. To view the documentation on the EntryType property's possible values, go to the Microsoft Developer Network (MSDN) Web site at http://msdn.microsoft.com/library/en-us/e2k3/e2k3/_wmiref_pr_exchange_messagetrackingentryentrytype.asp.

In addition to the five WMI providers found in Exchange 2000 SP2, Exchange 2003 offers five new WMI providers in the Root\MicrosoftExchangeV2 namespace: ExchangeFolderTreeProvider, ExchangeMapiTableProvider, ExchangePublicFolderProvider, ExchangeQueue2Provider, and ExchangeServerProvider. So, when you install Exchange 2003, you're installing a total of 10 WMI providers, which support more than 20 WMI classes in various management areas of Exchange 2003.

Any WMI consumer (i.e., any application that can access and use WMI data) can use the WMI classes that the Exchange 2003 installation adds to the Common Information Model (CIM) repository. Therefore, a Windows Script Host (WSH) script, a WMI event consumer provider (e.g., SMTP permanent event consumer), or enterprise-management software (e.g., HP OpenView Operations for Windows) can act as a WMI consumer. Let's look at how to use WSH scripts to access and use the Exchange 2003 WMI management information. I discuss only the new providers that Exchange 2003 adds. I won't discuss the five original Exchange WMI providers because they're well documented. If you're interested in more details, see the Microsoft article "Automating Exchange 2000 Management with Windows Script Host" (http://www.microsoft.com/technet/prodtechnol/exchange/2000/maintain/ex2kwsh.mspx). For the same reason, I won't cover WMI basics. If you're unfamiliar with WMI, check out the references at http://msdn.microsoft.com/library/en-us/wmisdk/wmi/further_information.asp.

Exchange 2003's five new providers support 15 new WMI classes. These providers and their classes fall into the following categories:•
Exchange server management

Exchange logon management

Exchange mailboxes

Exchange public folders and folder tree management

Exchange SMTP and X400 queues management

Because these categories cover a lot of material, I'm splitting this article into three parts. I'll cover the first three categories in Part 1, the fourth category in Part 2, and the fifth category in Part 3.
Top of page
Exchange Server Management

For Exchange server management tasks, you use the ExchangeServerProvider. This provider supports the Exchange_Server class, which let's you retrieve information about an Exchange 2003 server, such as the server's Administrative Group or Exchange version.

Let's begin by looking at how you use the Exchange_Server class to perform a simple task: obtaining a list of all the available Exchange servers in an organization. The article "Exchange 2000 SP2 WMI Updates," January 2003, http://www.winnetmag.com/microsoftexchangeoutlook, InstantDoc ID 27211, includes a script named GetCollectionOfInstances.wsf, which uses a WMI Query Language (WQL) query to list all instances of a class. If you run the command
GetCollectionOfInstances.wsf
"Select * From Exchange_Server"
/NameSpace:Root\MicrosoftExchangeV2

from the command-shell window, you can obtain a list of all the available Exchange servers in your organization. Note that the script shows only those properties that have a value. Figure 1 (http://www.winnetmag.com/microsoftexchangeoutlook, InstantDoc ID 40755) shows sample data from running GetCollectionOfInstances.wsf against the Exchange_Server class.

FIGURE 1: Sample Exchange_Server class output
C:\>GetCollectionOfInstances.wsf "Select * From Exchange_Server"
/Namespace:root\MicrosoftExchangeV2
/Machine:VM10284346B.LissWare.Net
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

AdministrativeGroup: ..................... Second Administrative Group
CreationTime: ............................ 20030731154649.000000+000
DN: ...................................... CN=VM10284346F,CN=Servers,
CN=Second Administrative Group,
CN=Administrative Groups,
CN=LissWareNET,CN=Microsoft Exchange,
CN=Services,
CN=Configuration,DC=LissWare,DC=NET
ExchangeVersion: ......................... Version 6.5 (Build 6944.4)
*FQDN: ................................... VM10284346F.LissWare.NET
GUID: .................................... {0B5A401B-832F-444B-8984-7FAEE70579C8}
IsFrontEndServer: ........................ FALSE
LastModificationTime: .................... 20030731155613.000000+000
MessageTrackingEnabled: .................. FALSE
MessageTrackingLogFileLifetime: .......... 7
MessageTrackingLogFilePath: .............. C:\Program Files\Exchsrvr\VM10284346F.log
MonitoringEnabled: ....................... TRUE
MTADataPath: ............................. C:\Program Files\Exchsrvr\mtadata
Name: .................................... VM10284346F
RoutingGroup: ............................ First Routing Group
SubjectLoggingEnabled: ................... FALSE
Type: .................................... 1
AdministrativeGroup: ..................... First Administrative Group
CreationTime: ............................ 20030720180526.000000+000
DN: ...................................... CN=VM10284346B,CN=Servers,
CN=First Administrative Group,
CN=Administrative Groups,
CN=LissWareNET,CN=Microsoft Exchange,
CN=Services,
CN=Configuration,DC=LissWare,DC=NET
ExchangeVersion: ......................... Version 6.5 (Build 6944.4)
*FQDN: ................................... VM10284346B.LissWare.NET
GUID: .................................... {A70378F2-9689-4AA8-B729-AC9DF8A59F98}
IsFrontEndServer: ........................ FALSE
LastModificationTime: .................... 20030720181104.000000+000
MessageTrackingEnabled: .................. FALSE
MessageTrackingLogFileLifetime: .......... 7
MessageTrackingLogFilePath: .............. C:\Program Files\Exchsrvr\VM10284346B.log
MonitoringEnabled: ....................... TRUE
MTADataPath: ............................. C:\Program Files\Exchsrvr\mtadata
Name: .................................... VM10284346B
RoutingGroup: ............................ First Routing Group
SubjectLoggingEnabled: ................... FALSE
Type: .................................... 1

You can download GetCollectionOfInstances.wsf as well as all the other scripts discussed in this article from the Exchange & Outlook Administrator Web site. Go to http://www.winnetmag.com/microsoftexchangeoutlook, enter InstantDoc ID 40755 in the InstantDoc ID box, then click Download the Code. To run GetCollectionOfInstances.wsf and the other scripts in this article, you must have Administrator permission if the namespace is accessed remotely or user permission if you access the namespace locally. If you use the user permission, make sure you can log on locally to the server.

Although learning about an Exchange server is interesting, being able to update that information would be more helpful. Using the Exchange_Server class's four read/write properties (i.e., AdministrativeNote, Message-TrackingLogFileLifetime, MonitoringEnabled, and SubjectLoggingEnabled) and two methods (i.e., MoveMTAData and EnableMessageTracking), you can do just that. For example, let's look at how you can use the AdministrativeNote property to update an Exchange server's administrative note and the EnableMessageTracking method to enable message tracking on an Exchange server.

Using the AdministrativeNote property. The script AdminNote.wsf, which Listing 1 shows, is a Windows Script (WS) file that leverages the AdministrativeNote property and the XML features that WSH 5.6 provides. The script uses the TinyErrorHandler.vbs file, which contains the ErrorHandler function. This function helps handle errors that occur during script execution.

Next, AdminNote.wsf creates an SWbemLocator object, which the script uses for the WMI connection. As the code at callout A in Listing 1 shows, the script uses a user ID and password to complete the WMI connection. When the user ID and password are empty strings, the script makes the connection under the security context of the user who's running the script. If you need to run the script under a different security context, you can add a user ID and password in the code at callout A.

Callout A highlights two additional lines that you must customize before you run AdminNote.wsf. First, you must change the cComputerName constant's value to the Fully Qualified Domain Name (FQDN) of an Exchange computer in your organization. In addition, you'll probably want to change the cAdministrativeNote constant's string to a more suitable administrative note.

After establishing the WMI connection, AdminNote.wsf uses the cComputerName constant's FQDN to retrieve an instance of the Exchange_Server class. This instance represents an Exchange 2003 server and its set of information (e.g., the Administrative Group, Exchange version, message-tracking status). Next, the script displays the current value of the AdministrativeNote property, after which it replaces that value with the value assigned to the cAdministrativeNote constant. The script then updates the Exchange_Server instance by invoking the Put_method, which the SWbemObject exposes. (If you're unfamiliar with the SWbemLocator or SWbemObject objects, you can learn about them at http://msdn.microsoft.com/library/en-us/wmisdk/wmi/scripting_api_objects.asp.) After the script saves the instance, the change is visible in Exchange System Manager (ESM).

You can adapt AdminNote.wsf to update the other read/write properties of the Exchange_Server class. Only the name of the property to update and its respective data type will vary (e.g., string data versus Boolean data when appropriate). Callout B in Listing 1 highlights the line to change to read a different property. Callout C in Listing 1 highlights the line to change to update a different property.AdminNote.wsf is a simple script that demonstrates a structure that's common to most of the WSH WMI scripts in this article. Therefore, I discuss only variations of this structure that won't be familiar to you.

Using the EnableMessageTracking method. The EnableMessageTracking method lets you enable or disable message tracking on an Exchange server. The script MessageTracking.wsf, which Listing 2 shows, illustrates how to use the EnableMessageTracking method. The overall logic of the code is basically the same as that in AdminNote.wsf. The major change resides in the method invocation. As the code at callout B in Listing 2 shows, the EnableMessageTracking method requires two parameters. The first parameter is a Boolean value that enables (True=Enabled) or disables (False=Disabled) message tracking. The second parameter is a string that specifies the message-tracking log's pathname. The script uses constants (cMessageTrackingEnabled and cMessageTrackingLogFilePath, respectively) to provide both of these parameters.

If you want to use this script, you need to customize the cMessageTrackingEnabled and cMessageTrackingLogFilePath constants as well as the other constants that callout A in Listing 2 highlights. If you want to use the MoveMTAData method to move Message Transfer Agent (MTA) files to another location, you can adapt MessageTracking.wsf by changing the invoked method and the input parameters. You can find the documentation for both methods at http://msdn.microsoft.com/library/en-us/e2k3/e2k3/_wmiref_cl_exchange_server.asp.
Top of page
Exchange Logon Management

For Exchange logon management tasks, you use the ExchangeMapiTableProvider. This provider supports the Exchange_Logon class, which represents the users currently logged on to an Exchange 2003 server. The Exchange_Logon class has a set of read-only properties and doesn't have any method. The documentation for the properties is available from Microsoft at http://msdn.microsoft.com/library/enus/e2k3/e2k3/_wmiref_cl_exchange_logon.asp. You can use GetCollectionOfInstances.wsf with the WQL query
"Select * From Exchange_Logon"

to obtain a list of all instances and properties of the Exchange_Logon class. You can limit the scope of the query to a specific mailbox by specifying the mailbox's display name. To do so, you use the Where statement in a WQL query, such as
"Select * From Exchange_Logon
Where MailboxDisplayName=
'LISSOIR Alain'"

Figure 2 shows sample data from running this query.

FIGURE 2: Sample Exchange_Logon class output
C:\>GetCollectionOfInstances.wsf "Select * From Exchange_Logon
Where MailboxDisplayName='LISSOIR Alain'"
/Machine:vm10284346b.LissWare.Net
/NameSpace:root\MicrosoftExchangeV2
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

AdapterSpeed: ............................ 10000
ClientIP: ................................ 192.10.10.1
ClientMode: .............................. 2
ClientName: .............................. VM10284346A.LissWare.NET
ClientVersion: ........................... 11.0.5329.6
CodePageID: .............................. 1252
FolderOperationRate: ..................... 0
LastOperationTime: ....................... 20030804213440.000325+***
Latency: ................................. 0
LocaleID: ................................ 1033
LoggedOnUserAccount: ..................... VMLISSWARENET\alain.lissoir
LoggedOnUsersMailboxLegacyDN: ............ /o=LissWareNET
/ou=First Administrative Group
/cn=Recipients/cn=alain.lissoir
LogonTime: ............................... 20030804213440.000325+***
MacAddress: .............................. 00-0C-29-21-A4-91
MailboxDisplayName: ...................... LISSOIR Alain
MailboxLegacyDN: ......................... /o=LissWareNET
/ou=First Administrative Group
/cn=Recipients/cn=alain.lissoir
.
.
*ServerName: ............................. VM10284346B
*StorageGroupName: ....................... First Storage Group
*StoreName: .............................. Mailbox Store (VM10284346B)
StoreType: ............................... 1
StreamOperationRate: ..................... 0
TableOperationRate: ...................... 0
TotalOperationRate: ...................... 0
TransferOperationRate: ................... 0

AdapterSpeed: ............................ 10000
ClientIP: ................................ 192.10.10.1
ClientMode: .............................. 2
ClientName: .............................. VM10284346A.LissWare.NET
ClientVersion: ........................... 11.0.5329.6
CodePageID: .............................. 1252
FolderOperationRate: ..................... 3
LastOperationTime: ....................... 20030805073649.000212+***
Latency: ................................. 3195
LocaleID: ................................ 1033
LoggedOnUserAccount: ..................... VMLISSWARENET\alain.lissoir
LoggedOnUsersMailboxLegacyDN: ............ /o=LissWareNET
/ou=First Administrative Group
/cn=Recipients/cn=alain.lissoir
LogonTime: ............................... 20030805073623.000381+***
MacAddress: .............................. 00-0C-29-21-A4-91
MailboxDisplayName: ...................... LISSOIR Alain
MailboxLegacyDN: ......................... /o=LissWareNET
/ou=First Administrative Group
/cn=Recipients/cn=alain.lissoir
.
.
*ServerName: ............................. VM10284346B
*StorageGroupName: ....................... First Storage Group
*StoreName: .............................. Public Folder Store (VM10284346B)
StoreType: ............................... 2
StreamOperationRate: ..................... 2
TableOperationRate: ...................... 17
TotalOperationRate: ...................... 41
TransferOperationRate: ................... 0

You can gather a lot of mailbox and user information from this output. For example, you can learn about the user account (LoggedOnUserAccount property) that's connected to the mailbox, the store to which the user is connected (StoreName property), the IP address of the client (ClientIP property), and the client software version (ClientVersion property), which corresponds to Microsoft Office Outlook 2003. Note that with earlier versions of Outlook and with Internet protocol-based clients such as Outlook Express, not all properties are initialized. For nonMessaging API (non-MAPI) clients, the client version might be SMTP or OLE DB. You can have more than one connection listed in the output. For example, you can have two connections: one to the mailbox store and one to the public folder store. The output often shows several Exchange_Logon instances for one client. Therefore, to be exact, the Exchange_Logon class represents the client connections more than it represents the client logons, even if it presents some logon information, such as the LogonTime property.

Although the output in Web Figure 2 is useful for tracking messages, tracking user logons only when users log on to Exchange can be more revealing. To show the properties of the Exchange_Logon class only at that time, you must use a different WQL query, called a WQL event query. "Exchange 2000 SP2 WMI Updates" provides a script called GenericEventAsyncConsumer.wsf that submits such a query. Therefore, to obtain the same information as before but only at logon time, you use the WQL query
"Select * From
__InstanceOperationEvent
Within 10 Where
TargetInstance ISA
'Exchange_Logon' And
TargetInstance.MailboxDisplayName=
'LISSOIR Alain'"
with GenericEventAsyncConsumer.wsf.
Top of page
Exchange Mailbox Management

For Exchange mailbox management tasks, you use the ExchangeMapiTableProvider's Exchange_Mailbox class. This class provides a series of read-only properties and two methods (i.e., Purge and Reconnect) that you can use to manage mailboxes. The documentation for the Exchange_Mailbox properties and methods is at http://msdn.microsoft.com/library/en-us/e2k3/e2k3/_wmiref_cl_exchange_mailbox.asp.

Some of the Exchange_Mailbox properties return mailbox-related information, such as the last logon time (LastLogonTime property), the last logoff time (LastLogoffTime property), and the name of the last user who logged on to the mailbox (LastLoggedOnUserAccount property). Other Exchange_Mailbox properties provide information about the mailbox location on the Exchange server. This information includes the server name (ServerName property), storage group (SG) name (StorageGroupName property), and store name (StoreName property). The Exchange_Mailbox class also exposes information about the size (in bytes) of a mailbox (Size property) and the number of items in the mailbox (TotalItems property).

The Purge and Reconnect methods' roles relate to fixing orphaned mailboxes. (You must handle other mailbox management tasks, such as creating, moving, or deleting an Exchange mailbox, through Collaboration Data Objects for Exchange Management—CDOEXM.) If an administrator uses the Microsoft Management Console (MMC) Active Directory Users and Computers snap-in to delete a user account but doesn't delete the mailbox, the mailbox is left in a disconnected state. After Exchange's Cleanup Agent runs, the mailbox in the Exchange Mailbox store is left without a user assigned to it. At that time, Exchange gives the administrator the chance to physically delete the mailbox from the store, which is the aim of the Purge method, or to reconnect the mailbox to an existing user, which is the aim of the Reconnect method.

The script Reconnect.wsf demonstrates how to use the Reconnect method to reconnect an Exchange mailbox to an existing user account. The structure of Reconnect.wsf is similar to that of AdminNote.wsf. However, slight differences exist. The script header starts with the definition of two constants: cMailboxDisplayName, which specifies the display name of the mailbox to reconnect, and cUserAccount, which specifies the user account to which to reconnect the mailbox.

To locate the mailbox, the script uses a WQL query, such as
"Select * From Exchange_Mailbox
Where MailboxDisplayName=
'LISSOIR Alain'"

After this query executes, the script enumerates a collection of mailboxes that match the selection criterion. In other words, the script isolates the mailbox by using a property whose value isn't guaranteed to be unique. Although you could specify the mailbox's globally unique identifier (GUID), which is guaranteed to be unique, in the MailboxGUID property, using the mailbox's display name is easier. Trying to find a mailbox's GUID, then trying to enter it without an error, would make the script difficult to use.

Because the mailbox name might not be unique, the script checks to see whether the collection contains only one mailbox, as the code excerpt in Listing 3 shows. If the script finds more than one mailbox, it displays a message that informs the operator about the ambiguity. If the script finds only one mailbox, it executes the Reconnect method. This method has two required parameters, which the script supplies through the cMailboxDisplayName and cUserAccount constants.

Although the WQL query I just showed you finds the mailbox, you don't have any guarantee that the mailbox is disconnected from a user. To determine whether a mailbox is disconnected, you can use the Exchange_Mailbox class's DateDiscoveredAbsentInDS property. This property indicates when the store detected that the mailbox no longer had a corresponding user account. When this property contains a date in the Distributed Management Task Force (DMTF) format, it's a disconnected mailbox. For more information about the DMTF format, go to http://msdn.microsoft.com/library/enus/wmisdk/wmi/date_and_time_format.asp.

To locate a mailbox using a specific display name and to ensure that the mailbox is disconnected, you can use an improved WQL query that narrows the search's scope:
"Select * From Exchange_Logon
Where MailboxDisplayName=
'LISSOIR Alain' And
DateDiscoveredAbsentInDS
IS NOT Null"

Finally, to ensure a successful execution of the Reconnect method, you must follow these guidelines:•
Run the script on the Exchange server on which the disconnected mailbox resides. Even when WMI is Distributed COM (DCOM)based, running the script remotely causes the Reconnect method to fail.

Select a user ID that exists in AD by referencing the sAMAccountName of that user ID (which is the legacy logon name). If you specify a domain and username or a user principal name (UPN), the Reconnect method will fail. Only an sAMAccountName is accepted.

If you don't follow these guidelines, the Reconnect mailbox method will fail. You'll get the following error message: An unknown ADSI user object was requested. Make sure you have the required permissions and/or you are running on the Exchange Server to invoke this method.
Top of page
WMI and CDOEXM

The addition of WMI's providers and classes has improved object management in Exchange 2003. Some WMI classes provide information that you can also obtain with CDOEXM. Take, for example, WMI's Exchange_Server class. The Exchange_Server class's Name property and CDOEXM's Name property both provide the Exchange server's name. Similarly, the Exchange_Server class's ServerType property and CDOEXM's Type property both provide the server's type (i.e., back-end or front-end server). Other Exchange_Server class properties (e.g., the Exchange_Server class's MonitoringEnabled property) and methods (e.g., the Exchange_Server class's MoveMTAData method) nicely complement the CDOEXM features. And the addition of the ExchangeMapiTableProvider WMI provider to Exchange 2003 enhances the management of Exchange in two areas: user logon management and mailbox management. Although these two technologies expose a complementary (and sometimes redundant) set of information, both technologies contribute to the expansion of Exchange server manageability.TABLE 1: WMI Providers and Classes That Exchange 2003 and Exchange 2000 Introduced
Provider Name (Namespace) Provider Classes Description of Classes
Exchange 2003

ExchangeFolderTreeProvider (Root\MicrosoftExchangeV2)
Exchange_FolderTree
Provides information about public and private folder trees on Exchange MicrosoftExchangeV2) servers.

ExchangeMapiTableProvider (Root\MicrosoftExchangeV2)
Exchange_Logon
Represents the users currently logged on to Exchange.

Exchange_Mailbox
Returns information about Exchange mailboxes.

ExchangePublicFolderProvider (Root\MicrosoftExchangeV2)
Exchange_PublicFolder
Provides properties and methods for working with Exchange public folders.

Exchange_ScheduleInterval
Provides information about the start and stop time of the public folder replication schedule. Instances of this class are returned as members of an array from the ReplicationSchedule property, which the Exchange_PublicFolder class exposes.

ExchangeQueue2Provider (Root\MicrosoftExchangeV2)
Exchange_QueueCacheReloadEvent
Provides information about when the queue’s cache was reloaded.

Exchange_SMTPLink
Provides methods for controlling an SMTP Exchange Link. Inherits all the properties of the Exchange_Link class.

Exchange_X400Link
Provides methods for controlling a X400 Exchange Link. Inherits all its properties from the Exchange_Link class.

Exchange_QueueX400VirtualServer
Returns properties for X400 queue virtual servers. Inherits all its properties from the Exchange_QueueVirtualServer class.

Exchange_QueueSMTPVirtualServer
Returns properties for SMTP queue virtual servers. Provides two methods in addition to the properties it inherits from the Exchange_QueueVirtualServer class.

Exchange_QueuedX400Message
Provides methods to work with Exchange messages currently in an X400 queue.

Exchange_QueuedSMTPMessage
Provides methods to work with Exchange messages currently in an SMTP queue.

Exchange_SMTPQueue
Returns properties for SMTP queues. Inherits all its properties from the Exchange_Queue class.

Exchange_X400Queue
Returns properties for X400 queues. This class inherits all its properties from the Exchange_Queue class.

ExchangeServerProvider (Root\MicrosoftExchangeV2)
Exchange_Server
Provides properties and methods for working with Exchange servers.
Exchange 2000 SP2

ExchangeDsAccessProvider (Root\MicrosoftExchangeV2)
Exchange_DSAccessDC
Provides information about Active Directory (AD) and Exchange Server 5.5 domain controllers (DCs) that are accessible to the Exchange 2000 DSAccess service.

ExchangeMessageTrackingProvider Root\MicrosoftExchangeV2)
Exchange_MessageTrackingEntry
Provides information about events that have occurred to the message during the time it was under the control of the computer running Exchange 2000.
Exchange 2000

ExchangeClusterProvider (Root\CIMV2\Applications\Exchange)
ExchangeClusterResource
Returns information about an Exchange cluster resource.

ExchangeQueueProvider (Root\CIMV2\Applications/Exchange)
ExchangeLink
Returns information about message-handling links between mail servers. A link can contain zero or more ExchangeQueue objects, depending on the current message traffic along the link. In ESM, these links are called queues.

ExchangeQueue
Returns information about the dynamic queues created to transfer individual messages between mail servers. ExchangeQueue is part of ExchangeLink. ExchangeQueue objects aren’t the same as the queues that ESM lists.

ExchangeRoutingTableProvider (Root\CIMV2\Applications\Exchange)
ExchangeServerState
Returns information about the computer running Exchange 2000.

ExchangeConnectorState
Returns information about an Exchange connector.

Top of page
Listing 1: The script AdminNote.wsf
<?xml version="1.0"?>
<package>
<job>
<?job error="True" debug="True" ?>
<script language="VBScript" src=".\Functions\TinyErrorHandler.vbs" />
<object progid="WbemScripting.SWbemLocator" _
id="objWMILocator" reference="true"/>
<script language="VBscript">
<![CDATA[
Const cWMINameSpace = "root\MicrosoftExchangeV2"
' BEGIN CALLOUT A
Const cUserID = ""
Const cPassword = ""
Const cComputerName = "VM10284346B.LissWare.Net"
Const cAdministrativeNote = "This is my administrative note!"
' END CALLOUT A
On Error Resume Next

objWMILocator.Security_.AuthenticationLevel = _
wbemAuthenticationLevelDefault
objWMILocator.Security_.ImpersonationLevel = _
wbemImpersonationLevelImpersonate
Set objWMIServices = _
objWMILocator.ConnectServer(cComputerName, _
cWMINameSpace, cUserID, cPassword)
Set objWMIInstance = _
objWMIServices.Get _
("Exchange_Server.FQDN='" & cComputerName & "'")
If Err.Number Then ErrorHandler (Err)

' BEGIN CALLOUT B
WScript.Echo "Current Administrative Note is '" & _
objWMIInstance.AdministrativeNote & "'."
' END CALLOUT B

' BEGIN CALLOUT C
objWMIInstance.AdministrativeNote = cAdministrativeNote
WScript.Echo "Updated Administrative Note is '" & _
cAdministrativeNote & "'."
' END CALLOUT C

objWMIInstance.Put_ (wbemChangeFlagUpdateOnly Or _
wbemFlagReturnWhenComplete)
If Err.Number Then ErrorHandler (Err)
]]>
</script>
</job>
</package>
Top of page
Listing 2: The script MessageTracking.wsf
<?xml version="1.0"?>
<package>
<job>
<?job error="True" debug="True" ?>
<script language="VBScript" _
src=".\Functions\TinyErrorHandler.vbs" />
<object progid="WbemScripting.SWbemLocator" _
id="objWMILocator" reference="true"/>
<script language="VBscript">
<![CDATA[
Option Explicit
Const cWMINameSpace = "root\MicrosoftExchangeV2"
' BEGIN CALLOUT A
Const cUserID = ""
Const cPassword = ""
Const cComputerName = "VM10284346B.LissWare.Net"
Const cMessageTrackingEnabled = True
Const cMessageTrackingLogFilePath = _
"C:\Program Files\Exchsrvr\VM10284346B.log"
' END CALLOUT A
Dim objWMIServices
Dim objWMIInstance
On Error Resume Next

objWMILocator.Security_.AuthenticationLevel = _
wbemAuthenticationLevelDefault
objWMILocator.Security_.ImpersonationLevel = _
wbemImpersonationLevelImpersonate

Set objWMIServices = _
objWMILocator.ConnectServer(cComputerName, _
cWMINameSpace, cUserID, cPassword)
If Err.Number Then ErrorHandler (Err)
Set objWMIInstance = _
objWMIServices.Get _
("Exchange_Server.FQDN='" & cComputerName & "'")
If Err.Number Then ErrorHandler (Err)
WScript.Echo "Current Message Tracking status is '" & _
objWMIInstance.MessageTrackingEnabled & "'."
' BEGIN CALLOUT B
objWMIInstance.EnableMessageTracking _
cMessageTrackingEnabled, _
cMessageTrackingLogFilePath
' END CALLOUT B
If Err.Number Then ErrorHandler (Err)

Set objWMIInstance = Nothing
Set objWMIServices = Nothing
]]>
</script>
</job>
</package>
Top of page
Listing 3: Excerpt from Reconnect.wsf
If Err.Number Then ErrorHandler (Err)

Set objWMIInstances = objWMIServices.ExecQuery _
("Select * From Exchange_Mailbox" & _
" Where MailboxDisplayName='" & cMailboxDisplayName & "'")

If Err.Number Then ErrorHandler (Err)

If objWMIInstances.Count = 1 Then
For Each objWMIInstance in objWMIInstances
WScript.Echo "Reconnecting mailbox '" & _
cMailboxDisplayName & _
"' to '" & cUserAccount & "' user account ..."
objWMIInstance.Reconnect cUserAccount
If Err.Number Then ErrorHandler (Err)
WScript.Echo "Mailbox '" & cMailboxDisplayName &amp; _
"' reconnected to '" & cUserAccount & "'."
Next
Else
If objWMIInstances.Count = 0 Then
WScript.Echo "There is no mailbox with the '" & _
cMailboxDisplayName & "' display name ..."
Else
WScript.Echo "There is more than 1 mailbox with the '" & _
cMailboxDisplayName & "' same display name ..."
End If
End If

© 2004 Exchange & Outlook Administrator. All rights reserved.

We at Microsoft Corporation hope that the information in this work is valuable to you. Your use of the information contained in this work, however, is at your sole risk. All information in this work 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 Microsoft Corporation. Microsoft Corporation 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. All prices for products mentioned in this document are subject to change without notice.

 

1 comment:

Alex said...

There are numerous softwares at the Inet, but one day I was in a nice mess and no one of programs couldn't assist me. My point of view that this application has more facilities for resolving other problems - exchange disaster recovery.

Google