Finding disk space used by Exchange

Originally published July 11, 2006

 

I apologize for the long absence, but I've been tied up in Exchange 2007 testing and learning. If you haven't seen it yet - just wait. You'll be very impressed, especially from the administrator's perspective. Especially when used in concert with Outlook 2007, it's a dream to use.

A common request is to find out how much diskspace that exchange is using in all of the various EDB and STM files spread out everywhere. The script below should work on Exchange 2000, 2003, and 2007 (although I truly can't speak about the final capabilities of E12 yet - I don't know them anymore than anyone else!).

This is the output from one of my environments:

Exchange Organization Name: We Do Email best
Default SMTP address for organization: e12beta.com

All Exchange Servers in forest DC=e12beta,DC=com
 Server Name: VOLCANO
 Server Name: E12BETA
 
Server name: VOLCANO
  Storage group: First Storage Group
    Store: Public Folder Store (VOLCANO)
      EDB file: C:\Program Files\Exchsrvr\mdbdata\pub1.edb
      Size: 11 megabytes
      SLV file: C:\Program Files\Exchsrvr\mdbdata\pub1.stm
      Size: 4 megabytes
      Store Size Total: 15 megabytes
    Store: Mailbox Store (VOLCANO)
      EDB file: C:\Program Files\Exchsrvr\mdbdata\priv1.edb
      Size: 6 megabytes
      SLV file: C:\Program Files\Exchsrvr\mdbdata\priv1.stm
      Size: 8 megabytes
      Store Size Total: 14 megabytes
    Storage Group total: 29 megabytes
  Server total: 29 megabytes
Server name: E12BETA
  Storage group: First Storage Group
    Store: Public Folder Store (E12BETA)
      EDB file: D:\Exchsrvr\MDBDATA\pub1.edb
      Size: 897 megabytes
      SLV file: D:\Exchsrvr\MDBDATA\pub1.stm
      Size: 212 megabytes
      Store Size Total: 1,109 megabytes
    Store: 7-Day-DIR
      EDB file: D:\Exchsrvr\MDBDATA\7-Day-DIR.edb
      Size: 22,189 megabytes
      SLV file: D:\Exchsrvr\MDBDATA\7-Day-DIR.stm
      Size: 15,296 megabytes
      Store Size Total: 37,485 megabytes
    Store: DBI Archive Store
      EDB file: D:\Exchsrvr\MDBDATA\DBI Archive Store.edb
      Size: 4,752 megabytes
      SLV file: D:\Exchsrvr\MDBDATA\DBI Archive Store.stm
      Size: 4,288 megabytes
      Store Size Total: 9,040 megabytes
    Store: Mailbox Store (E12BETA)
      EDB file: D:\Exchsrvr\MDBDATA\priv1.edb
      Size: 92,861 megabytes
      SLV file: D:\Exchsrvr\MDBDATA\priv1.stm
      Size: 46,632 megabytes
      Store Size Total: 139,493 megabytes
    Store: Mailbox Store 2
      EDB file: D:\Exchsrvr\MDBDATA\Mailbox Store 2.edb
      Size: 4,047 megabytes
      SLV file: D:\Exchsrvr\MDBDATA\Mailbox Store 2.stm
      Size: 18 megabytes
      Store Size Total: 4,065 megabytes
    Storage Group total: 191,192 megabytes
  Storage group: Second Storage Group
    Store: Mailbox Store 3
      EDB file: D:\Exchsrvr\SecondStorageGroup\Mailbox Store 3.edb
      Size: 5,180 megabytes
      SLV file: D:\Exchsrvr\SecondStorageGroup\Mailbox Store 3.stm
      Size: 1,508 megabytes
      Store Size Total: 6,688 megabytes
    Storage Group total: 6,688 megabytes
  Server total: 197,909 megabytes
Organization total: 197,938 megabytes

This script starts by discovering all of the Exchange servers present in your Exchange organization (it does this by reading through Active Directory for objects of a specific objectCategory - msExchExchangeServer). Next, it iterates through each Exchange server and discovers all of the storage groups on that server (by searching Active Directory of all objects beneath that server of objectCategory msExchStorageGroup) and then all of the stores beneath that server (which may be either public folder stores or mailbox stores).

Each store consists of an object within Active Directory that contains two attributes/properties (the object has many many properties - we are only interested in two of them right now). Those properties are msExchEDBFile and msExchSLVFile. Those properties contain the full path and filename of the EDB and STM file for that store relative to that server.

The script next manipulates the filename for accessing the file a little bit, taking a full pathname and filename and turning it into a UNC path and filename; this allows the script to be executed on any server in your organization.

Finally, using the capabilities of the intrinsic FileSystemObject, the script sets the size of the relevant file, formats it a little bit, and prints it out.

For each storage group a subtotal is generated, for each server a subtotal is generated, and for the entire organization a total is generated. This presents a nice little hierarchical view of your storage usage.

Below you will find the main script associated with this process. In the next posting to my blog, you'll find the include files. The name of the first file I call “exch-store-space.wsf”. It needs to be a WSF file so that the Windows scripting host doesn't assume that it's only jscript or vbscript - WSF means that there may be jobs, and include, and other fun stuff in the file. You should execute it something like this:

        cscript //nologo exch-store-space.wsf

So, without further ado, the script:

<job>
<script language="VBScript">
Option Explicit
</script>
<script language="VBScript" src="lib/constants.vbs" mce_src="lib/constants.vbs"      />
<script language="VBScript" src="lib/ado.vbs" mce_src="lib/ado.vbs"            />
<script language="VBScript" src="lib/report.vbs" mce_src="lib/report.vbs"         />
<script language="VBScript" src="lib/systeminfo.vbs" mce_src="lib/systeminfo.vbs"     />
<script language="VBScript" src="lib/queries.vbs" mce_src="lib/queries.vbs"        />
<script language="VBScript">
'
' exch-store-space.wsf
'
' This program reports on the space utilization of the EDB and STM
' files for all stores for all storage groups for all servers in the
' Exchange organization.
'
Dim arr, arrSG, arrStore
Dim s, s1, strServer
Dim i, j, k, orgTotal
Dim objFSO

Call GetSystemInfo
Call GetAllServers

Set objFSO = CreateObject ("Scripting.FileSystemObject")

arr = Split (strServerListDN, ";")

For i = LBound (arr) To UBound (arr)
 Dim serverTotal

 s = arr (i)
 strServer = Mid (Left (s, Instr (s, ",") - 1), 4)
 e "Server name: " & strServer

 Call GetStorageGroupsForServer (arr (i))

 arrSG = Split (strServerSGDN, ";")

 For j = LBound (arrSG) To UBound (arrSG)
  Dim sgTotal

  sgTotal = 0

  s = arrSG (j)
  s1 = Mid (Left (s, Instr (s, ",") - 1), 4)
  e Space (2) & "Storage group: " & s1

  Call GetStoresForStorageGroupLDAP (s)

  arrStore = Split (strStoreDN, ";")

  For k = LBound (arrStore) To UBound (arrStore)
   Dim obj, objFile, strFile, storeTotal

   storeTotal = 0

   s = arrStore (k)
   s1 = Mid (Left (s, Instr (s, ",") - 1), 4)
   e Space (4) & "Store: " & s1

   Set obj = GetObject ("LDAP://" & s)

   e Space (6) & "EDB file: " & obj.Get ("msExchEDBFile")
   ' must convert the file to a UNC path
   s = obj.Get ("msExchEDBFile")
   strFile = "\\" & strServer & "\" & _
    Left (s, 1) & "$" & Mid (s, 3)
   Set objFile = objFSO.GetFile (strFile)
   e Space (6) & "Size: " & _
    FormatNumber (objFile.Size / (1024 * 1024), 0) & _
    " megabytes"
   storeTotal = storeTotal + (objFile.Size / (1024 * 1024))

   e Space (6) & "SLV file: " & obj.Get ("msExchSLVFile")
   s = obj.Get ("msExchSLVFile")
   strFile = "\\" & strServer & "\" & _
    Left (s, 1) & "$" & Mid (s, 3)
   Set objFile = objFSO.GetFile (strFile)
   e Space (6) & "Size: " & _
    FormatNumber (objFile.Size / (1024 * 1024), 0) & _
    " megabytes"
   storeTotal = storeTotal + (objFile.Size / (1024 * 1024))

   e Space (6) & "Store Size Total: " & _
    FormatNumber (storeTotal, 0) & _
    " megabytes"
   sgTotal = sgTotal + storeTotal
  Next
  e Space (4) & "Storage Group total: " & FormatNumber (sgTotal, 0) & _
   " megabytes"
  serverTotal = serverTotal + sgTotal
 Next
 e Space (2) & "Server total: " & FormatNumber (serverTotal, 0) & " megabytes"
 orgTotal = orgTotal + serverTotal
Next
e "Organization total: " & FormatNumber (orgTotal, 0) & " megabytes"

Call ClearSystemInfo
</script>
</job>

Published Tuesday, November 13, 2007 8:30 PM by michael

Comments

Tuesday, November 13, 2007 8:36 PM by Michael's meanderings...

# Utility Libraries for Exchange Scripting

Originally published July 11, 2006 I write many many many Exchange scripts. There are some things that

Wednesday, May 28, 2008 5:29 PM by dpowers3

# re: Finding disk space used by Exchange

Nice script, but bug in it....totals run together when you multiple excchange servers.

Currently:

Next

e Space (2) & "Server total: " & FormatNumber (serverTotal, 0) & " megabytes"

orgTotal = orgTotal + serverTotal

Next

Should be:

Next

e Space (2) & "Server total: " & FormatNumber (serverTotal, 0) & " megabytes"

orgTotal = orgTotal + serverTotal

serverTotal = 0

Next

Thursday, August 07, 2008 11:25 AM by Michael's meanderings...

# Finding Disk Space Used by Exchange, version 2

In July of 2006, I had a blog entry named Finding Disk Space Used By Exchange , and it was quite well

# How to know where de exchange DB files are, and space free of disk | keyongtech

Pingback from  How to know where de exchange DB files are, and space free of disk | keyongtech

Tuesday, June 09, 2009 5:29 AM by Reporting Storage Size in Exchange

# Reporting Storage Size in Exchange

Pingback from  Reporting Storage Size in Exchange