Skip to main content


Showing posts from January, 2005

Displaying what version of Exchange your using (Enterprise or Standard) via Script

Somebody asked me this question this week and what I thought would be quite easy turned out to be a little hard. On a Exchange 2003 box there is a WMI class Exchange_Server that you can use to do this and there is a sample in the Exchange SDK here . But this WMI class isn’t available in Exchange 2000, The PSS knowledge base offers two solutions one is based on looking for event id 1217 or 1216 in the event log and the other one is to use the Guid from the Uninstall key in the registry and they supply all the Guid's for Exchange 2000 Q296587 . Unfortunately there didn’t seem to be the same information available for Exchange 2003. A check of the ExBPA which seems to be using the same method did yield all the GUID'S for Exchange 2003 as well as the SBS versions. The Exbpa actually makes quite a good scripting reference if you have a look at the “ExBPA.Config.xml” config file there’s quite a lot of good information about how they are going about retrieving various pieces of infor

Showing which DC your Exchange Server is using

I found this one the other day while looking for something else but its something that pops up for me now and again. If you want to find out which Domain Controller your Exchange server is currently using you can use the DirectoryServer property from the IExchangeserver Interface with CDOEXM. To use it in a script its just 3 lines Set iExchSvr = CreateObject("CDOEXM.ExchangeServer") "Servername" wscript.echo iExchSvr.DirectoryServer

Draft DL templates Script

I've been thinking a lot about DL's over the last week or so and have been running a few idea's around about how to use them in different ways. One idea was to create a bunch of DL's by scanning though the sent items folder of a mailbox and looking at any mail that had more then a certain number of recipients. Although this sounded like a good idea when I looked into it further it seemed that these type of emails where never usually just sent to a large number of recipients but rather there was a bunch of people in the To line another bunch being CC and maybe a few BCC'd. So what I though about instead of creating DL's why not just create some template emails that where addressed with all the TO,CC and BCC address's of people you sent these type of emails to and then store all these templates in a folder within the drafts folder. Out of this idea the following script was born, It uses CDO 1.2 basically because access to the recipients collection of a messag

Listing File Sizes with WMI

In my previous post on " Listing the file sizes of all Exchange Stores on all Exchange Servers in a Domain" I used the FSO (file system object) to get the details about the size of exchange store files and drive freespace. Somebody asked a question if there was another way to do this because in their network (as in many others) for security reasons the default admin shares (eg c$ d$) have been disabled. One way you can go about this is to use WMI and the CIM_DataFile class, If you have Windows 2000 and your store files are above 2 GB you need to make sure you have applied the following hotfix for this to work. But using the CIM_DataFile class is actually really easier it actually takes fewer lines of code then using FSO. For example to display the size of priv1.edb on a Exchange box once you know the location of the file its just two lines of code. Set edbfile = GetObject("winMgmts:!\\servername\root\cimv2:CIM_DataFile.Name='e

Tracking DL-usage with a public folder Event sink

This week I’ve been thinking about issues of trying to track DL usage in a large networks.The idea of tracking distribution list usage by adding a public folder to the DL has been around for a while and offers a good solution. Some problems that do arise from this method is how many folders do you create (eg one per DL) or do you dump then all into one collection spot. The other problem is if someone is BCC’ing the DL its very hard to determine which DL that a message that you tracked was sent to. Back in Exchange 5.5 you used to have a unique event logged (by the MTA which used to perform DL expansion) in the message tracking logs that you could use to work out DL usage. Now in Exchange 2 x DL expansion is handled by the categorizer which has its own tracking log event ID’s but the problem is there’s no difference between a Categorizer event logged for a message and one logged for a DL. The other challenge if you are going to use the Categorizer event on Exchange 2x is that for a cate

Displaying the Store file usage Trends via Script using the Event log

Continuing on from some of my previous scripts last month around mail store file usage and backup results this script expands on this idea a little. As I’ve mentioned previously when the backup runs on an Exchange server (as long as it’s using the Exchange backup API eg Brightstore, Veritas etc). It logs to the event log a whole lot of useful information about when it started when it stopped and how much data (the size of each database file) that is going to be backed up. Because the event log is a historical record depending on how you have your eventlogs setup you will have a record that goes back of a number of weeks or months of how large the database store files where when each of the backups occurred. All this information is stored in the eventid 220. So what this script does is like the others scripts before it is query AD for all the mail and public folder stores in your domain. Then query the exchange server’s event log for all the 220 events for a configured time period. I’v

Copying email from the Inbox to eml files on the file system

Somebody asked how to copy email from a mailbox or public folder to the file system using WebDAV. One way of doing this is to grab the email as stream using a WebDAV get as illustrated in the Exchange SDK here Once you have the email as a stream you can then use an ADO stream object's savetofile method to save it as an eml file. If you combine that with a webdav search you can then select all the emails in a certain folder and export this to a folder on the file system. The following example exports all the mail in a inbox to a folder on the c: drive called exp. I've posted a downloadable copy of this code here . server = "servername" mailbox = "mailbox" set fso = createobject("Scripting.FileSystemObject") strURL = "http://" & server & "/exchange/" & mailbox & "/inbox/" strURL1 = "http://" & server & "/exchange/" & mailbox & "/sent items/" strQuery = "
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.