TheTAZZone - Internet Chaos

check the storage limits on all mailboxes *not* using the default storage limits

ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE

Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network

Please refer to the original post as not all the script may be visible here.

This is a script I found that will check the storage limits on all mailboxes *not* using the default storage limits on an Exchange server. It outputs to a CSV file and is very handy for keeping track of users who’ve had their limits modified. If you’re an Exchange Admin, you know precisely what I’m talking about.

Code: Select all
' emailStorageLimts.vbs
' VBScript program to document users who do not have "Use Defaults"
' checked for their email storage.
' Copyright (c) 2005 Burt Johnson - bdjsoftware
'#######################################################################
Option Explicit

Dim objFSO, logFile
Dim oConnection1, oCommand1, rs, objUser
Dim Query

Const LDAP_TREE = "LDAP://DC=myDomain,DC=com"
Const ADS_SCOPE_SUBTREE   = 2
Const LOG_FILE   = "eMailStorageLimts.CSV"
'--------------------------------------------------------------------
' Set up log file
'--------------------------------------------------------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set logFile = objFSO.CreateTextFile(LOG_FILE)
'--------------------------------------------------------------------
' Create the connection and command object.
'--------------------------------------------------------------------
Set oConnection1 = CreateObject("ADODB.Connection")
Set oCommand1 = CreateObject("ADODB.Command")
'--------------------------------------------------------------------
' Open the connection.
'--------------------------------------------------------------------
oConnection1.Provider = "ADsDSOObject"  ' This is the ADSI OLE-DB provider name
oConnection1.Open "Active Directory Provider"
'---------------------------------------------------------------------
' Create a command object for this connection.
'---------------------------------------------------------------------
Set oCommand1.ActiveConnection = oConnection1
'---------------------------------------------------------------------
' Compose a search string.
'----------------------------------------------------------------------
oCommand1.CommandText = "Select distinguishedName from '" & LDAP_TREE & "' WHERE objectCategory='Person' AND objectClass='user'"
oCommand1.Properties("Page Size") = 7000
oCommand1.Properties("Timeout") = 120
oCommand1.Properties("Searchscope") = ADS_SCOPE_SUBTREE
oCommand1.Properties("Cache Results") = False
'----------------------------------------------------------------------
' Execute the query.
'----------------------------------------------------------------------
Set rs = oCommand1.Execute
'----------------------------------------------------------------------
' Navigate the record set
'----------------------------------------------------------------------
MsgBox("Starting Search")

While Not rs.EOF

Query = "LDAP://" & rs.Fields("distinguishedName")
Set objUser = GetObject(Query)
If objUser.mDBUseDefaults = "False" Then
logFile.WriteLine("""" & objUser.distinguishedName & """,""" & objUser.mDBOverHardQuotaLimit & """,""" & objUser.mDBOverQuotaLimit & """,""" & objUser.mDBStorageQuota & """")
End If

rs.MoveNext
Wend

Set logFile = Nothing
Set oCommand1 = Nothing
Set oConnection1 = Nothing
Set rs = Nothing
Set objUser = Nothing

msgBox("Done Searching")

The only thing that really needs editing is the LDAP name of the domain you’re running the script in. The line towards the bottom in the If statement is one long line, even though it may wrap on your screen.

One Response to check the storage limits on all mailboxes *not* using the default storage limits

  1. Security Guru November 26, 2008 at 6:01 am

    nice…I’ll have to try it out.

Leave a Reply

Your email address will not be published. Required fields are marked *

Advertise

If you'd like to advertise on The Mutt ( aka TheTAZZone.com ) feel free to contact us at: administration[at]thetazzone.com

TheTAZZone is a non-commercial entity. We do not sell any products or services ourselves. Our revenue comes from advertising and donations only.

We appreciate your support! Your advertising revenue ( or donations ) helps us to continue to upgrade, improve, and offset the costs of maintaining this site.

Donations can be made through the page ' Donate '.