Set mailbox limits (VBScript)

This code can be found in Chapter 5 of Exchange Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' This script was originally published in the Exchange Cookbook,
' (http://www.exchangebookcook.com). Written by Paul Robichaux, 
' Missy Koslosky, and Devin Ganger. Redistributed with permission 
' of the publisher, O'Reilly & Associates.

' This code gets and sets mailbox quotas on the specified user

' ------ SCRIPT CONFIGURATION ------
 strServerName = "<dc>" '  ' e.g. "CONT-EXBE01"	
 strUser= "<userName>" ' e.g. "Paul Robichaux"  
 strContainer = <container>,<forestDN>"	' e.g. ", CN=Users, dc=robichaux, dc=net" 
'  ------ END CONFIGURATION ---------

' get the target mailbox
what = "LDAP://" & strServerName & "/CN=" & strUser & strContainer
Set objMailbox = GetObject(what)

' get the warning limits; these gets will fail if
' the corresponding limit is not defined
On Error Resume Next
warnLimit = 0
prohibitSendLimit = 0
prohibitSendReceiveLimit = 0

warnLimit = objMailbox.Get ("mDBStorageQuota")
prohibitSendLimit = objMailbox.Get ("mDBOverQuotaLimit")
prohibitSendReceiveLimit = objMailbox.Get ("mDBOverHardQuotaLimit")

' display the limits, then bump each of them by 10Kb
Wscript.echo "Existing quotas for " & strUser
Wscript.echo "  warning limit:           " & warnLimit
Wscript.echo "  prohibit send limit:     " & prohibitSendLimit
Wscript.echo "  prohibit send/receive:   " & prohibitSendReceiveLimit
objMailbox.Put "mDBStorageQuota", warnLimit+10
objMailbox.Put "mDBOverQuotaLimit", prohibitSendLimit+10
objMailbox.Put "mDBOverHardQuotaLimit", prohibitSendReceiveLimit+10
objMailbox.SetInfo

This code has been viewed 3190 times.

New from the creators of TechTasks.com: StatSheet.com