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.

By admin

Former Freehand Freelance Graphic Illustrator... been online since 2004 ( late starter ), blogging since 2005, presently writing a suspense-thriller e-book that began as a screenplay.

One thought on “check the storage limits on all mailboxes *not* using the default storage limits”

Leave a Reply

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