Thursday, August 25, 2011

Errors when using vbscript to retrieve mailbox size information

One of my colleague was having problem running a vbscript which uses the WMI root\microsoftexchangev2 namespace and Exchange_Mailbox class to generate a mailbox size report for all the mailboxes on an Exchange 2003 server.

The script will create a log file to log the activities and a text file to store the result.  At first she double clicked on the vbs file to execute the script in the Exchange server itself.  So the script get handled by the Windows-based script host (Wscript.exe).  She waited for more than 10 minutes but the log file and text file remains empty except for some headers.  So she double clicked on the vbs file again to retry and this time she received an error message (Code: 800A0046).

image

This error was quite misleading and she thought that she lacked some permissions to connect to the Exchange server.  However, it was actually the locking of the log and text files that was causing the error 800A0046.  The first execution of the script which is handled by wscript.exe encountered an error but thanks to the “On Error Resume Next”, it went into an infinite loop causing the log and text files to be locked.  Checking the Windows Task Manager revealed that wscript.exe is still running.

image

I terminated the wscript.exe process and comment out the “On Error Resume Next” line.  I advised her to re-run the script using command-based script host (CScript.exe).  Re-run of the script showed a different error with an error code of 0x80041013.

image

Reviewing the script showed that it failed to create an instant of the Exchange_Mailbox class.  A quick check on the Exchange services, I noticed that the “Microsoft Exchange Management” service was stopped.

image

Starting the “Microsoft Exchange Management” service resolved the issue and she was able to generate the mailbox size report.

No comments: