Skip to main content

Posts

Showing posts from March, 2005

C# WMI Exchange samples

Somebody asked this morning about using WMI and Exchange in c#. There's a lot of good information on the Web about using the System.Management namespace to access WMI but not many Exchange specific C# samples at the moment. I decided to convert a few of the examples I've used in the scripts in my blog. The first is a simple mailbox size example System.Management.ConnectionOptions objconn = new System.Management.ConnectionOptions(); objconn.Impersonation = System.Management.ImpersonationLevel.Impersonate; objconn.EnablePrivileges = true; string cServername = "servername"; System.Management.ManagementScope exmangescope = new System.Management.ManagementScope(@"\\" + cServername + @"\root\MicrosoftExchangeV2",objconn); System.Management.ObjectQuery objquery = new System.Management.ObjectQuery("SELECT * FROM Exchange_Mailbox"); System.Management.ManagementObjectSearcher objsearch = new System.Management.ManagementObjectSearcher(exmangescope,o...

Data shaping ADSI and Exchange WMI information

I blogged last week about relating mailbox size data with mailbox quota data here . The main problem I had with the approach that I was using here is although it worked fine for 1 user when you wanted to relate a lot of data say the size of everybody’s mailbox on one particular server to the possible size of the mailbox quotas from either their account or mailbox store it gets a little slow. Data shaping is an ADO thing that allows you to build hierarchical relationships between two or more logical entities in a query. What this means is that I can take two or more separate data sources (via a disconnected recordset) and bung them together in a hierarchical tree (as long as you have a field that relates between the two sources). The guys over at Rolla do a lot better job of explaining it them me have a look at http://www.4guysfromrolla.com/webtech/060301-1.shtml and http://www.4guysfromrolla.com/webtech/100699-2.shtml In my particular scenario I want to shape data from 3 different d...

Looking for good Exchange scripts

Paul , Missy and Devin have started posting up some of the scripts from their forthcoming book on the Exchange Cookbook Blog . This should make good reading over the next few weeks. If you haven’t already check out their blog here

Relating Mailbox sizes to Mailbox quotas

Somebody asked last week about how to query mailbox sizes and mailbox quota information for a user. This is a interesting question there’s are a lot of different methods for querying mailboxes sizes most of these are listed in this KB . With Exchange 2003 you can use WMI to pull the mailbox size from the Exchange_mailbox class there’s a sample in the Exchange SDK here . With mailbox quotas what quota information will apply to your mailbox will differ depending on how quotas have been applied to the mailbox. Quotas can come from 1 of 3 locations, from a policy applied to the mail-store, by setting the quotas on the mail store itself and from quotas set on the mailbox directly. So to work out what quotas apply to a user you first need to query the user object in AD and look at the mDBUseDefaults property (which relates to the use store defaults check box in AD Users and Computers). If this is set to true (which is default) then you need to look at the mail-store object to see if quotas...
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.