This post arose out of a situation where I had given some bad poop (Army term for information) about how to control mailbox sizes by OU at Experts Exchange. I was mistakenly thinking of something smelling a lot better!
Any hoots, since I delayed the answer, I wrote this script to accomplish what the guy (I think) needed and without further delay, here it is.
This script takes arguments in the form of target, warning size, nosend size, and disable size. Sizes listed just as they would in ESM as no conversions take place. Some examples provided here.
- /ou:“ou=Southwest Sales,ou=sales”
/warn:80000 /nosend:90000 /disable:100000 - /ou:cn=users /warn:80000 /nosend:90000 /disable:100000
- /ou:cn=Helpdesk,cn=Atlanta,cn=users /warn:80000
/nosend:90000 /disable:100000
Notice as with any command line script, that the OU argument must be encapsulated in quotes to count as one argument if there are spaces in name of it. OU also goes for container.
Make sure (as in ESM) that disable is the largest, followed by nosend, and finally warning as the smallest. You don’t want your users to be disabled without warning I hope.
Sometime in the further, I will extend this script to reenable the defaults as well.
-
-
‘ Written by: Stacy Spear (Darkstar 3D)
-
‘ Date: April 30, 2007
-
‘ This code modifies the mailbox size limits of an entire container or OU. Run the command without arguments to get a help display
-
‘ Version History
-
‘1.0 - Original
-
-
‘Argument Check
-
If Wscript.Arguments.Named("ou") = "" or Wscript.Arguments.Named("warn") = "" or Wscript.Arguments.Named("nosend") = "" or Wscript.Arguments.Named("disable") = "" Then ‘Check for the named arguments
-
‘Send help message if arguments is not correct
-
Wscript.echo "You must specifiy the target OU and the sizes for Warning, Nosend,"
-
Wscript.echo "and Disable using syntax like this:"
-
Wscript.echo
-
Wscript.echo "modmbxperms.vbs /ou:""target ou"" /warn:80000 /nosend:90000 /disable:100000"
-
Wscript.echo "Account running this script MUST have enough AD rights to make these changes"
-
Wscript.Quit
-
End If
-
-
‘Connect to AD
-
Set RootDSE = GetObject("LDAP://RootDSE")
-
strDomain = RootDSE.Get("DefaultNamingContext")
-
ou = Wscript.Arguments.Named("ou") & "," & strDomain ‘ Build the LDAP connection string for the OU or container
-
-
‘Copy arguments to variables for ease of use
-
warn = Wscript.Arguments.Named("warn")
-
nosend = Wscript.Arguments.Named("nosend")
-
disable = Wscript.Arguments.Named("disable")
-
-
‘Query AD for members of the OU
-
Set objGroup = GetObject("LDAP://" & ou)
-
-
‘Update AD for each user in the OU
-
For each objUser in objGroup
-
If objUser.class="user" then
-
objUser.mDBUseDefaults = False ‘Toggle the switch for "Use Mailbox Store Defaults" to off
-
objUser.Put "mDBStorageQuota", warn ‘ Warning Limit
-
objUser.Put "mDBOverQuotaLimit", nosend ‘Nosend Limit
-
objUser.Put "mDBOverHardQuotaLimit", disable ‘Disable Mailbox Limit
-
objUser.SetInfo ‘Write object to AD
-
intCounter = intCounter +1 ‘Increment the counter
-
End if
-
next
-
WScript.Echo intCounter & " Limits Changed "
-
WScript.Quit
Comment by Stacy
6 June 21, 2007, 12:56 pm o'clock |
As stated previously, this code needs parameters to run. Without them, it fails and bombs out with giving you helpful hints on how to run it.
Comment by Aaron Saberan
5 June 18, 2007, 3:17 pm o'clock |
Stacy,
Sorry, but I still can’t get it to work.
I think I’ve tried just about all I can think of.
Let me outline my steps so maybe you can point out what I’m doing wrong.
First I’m pasting this text into Notepad:
‘ Written by: Stacy Spear (Darkstar 3D)
‘ Date: April 30, 2007
‘ This code modifies the mailbox size limits of an entire container or OU. Run the command without arguments to get a help display
‘ Version History
‘1.0 - Original
‘Argument Check
If Wscript.Arguments.Named(”ou”) = “GP Testing Only” or Wscript.Arguments.Named(”warn”) = “800″ or Wscript.Arguments.Named(”nosend”) = “900″ or Wscript.Arguments.Named(”disable”) = “1000″ Then ‘Check for the named arguments
‘Send help message if arguments is not correct
Wscript.echo “You must specifiy the target OU and the sizes for Warning, Nosend,”
Wscript.echo “and Disable using syntax like this:”
Wscript.echo
Wscript.echo “modmbxperms.vbs /ou:”"GP Testing Only”" /warn:800 /nosend:900 /disable:1000″
Wscript.echo “Account running this script MUST have enough AD rights to make these changes”
Wscript.Quit
End If
‘Connect to AD
Set RootDSE = GetObject(”LDAP://RootDSE”)
strDomain = RootDSE.Get(”DefaultNamingContext”)
ou = Wscript.Arguments.Named(”ou”) & “,” & strDomain ‘ Build the LDAP connection string for the OU or container
‘Copy arguments to variables for ease of use
warn = Wscript.Arguments.Named(”warn”)
nosend = Wscript.Arguments.Named(”nosend”)
disable = Wscript.Arguments.Named(”disable”)
‘Query AD for members of the OU
Set objGroup = GetObject(”LDAP://” & ou)
‘Update AD for each user in the OU
For each objUser in objGroup
If objUser.class=”user” then
objUser.mDBUseDefaults = False ‘Toggle the switch for “Use Mailbox Store Defaults” to off
objUser.Put “mDBStorageQuota”, warn ‘ Warning Limit
objUser.Put “mDBOverQuotaLimit”, nosend ‘Nosend Limit
objUser.Put “mDBOverHardQuotaLimit”, disable ‘Disable Mailbox Limit
objUser.SetInfo ‘Write object to AD
intCounter = intCounter +1 ‘Increment the counter
End if
next
WScript.Echo intCounter & ” Limits Changed ”
WScript.Quit
Then I am saving the file as Gptestingonly.vbs and running it from a command prompt (Start–>Run “cmd”) then I am running it from the root of the c drive by typing “Gptestingonly.vbs”. This gives me an error message such as “Expected Then in line…..” or “;” or something similar.
What am I doing wrong?
Comment by Stacy
4 May 24, 2007, 7:45 pm o'clock |
The sizes just like those listed in Exchange System Manager are all in kilobytes. So a 100mb limit would be listed as 100000. Of course this is approximately 100mb due to conversion factors.
I am thinking that you are modifying the help text in the script. You must provide command line arguments to the script like so:
modmbxperms.vbs /ou:“ou=Southwest Sales,ou=sales”
/warn:80000 /nosend:90000 /disable:100000
Thats all on one line. You can not just double-click the script to run it, must be at the command line, because you need the arguments.
Of course you could just create a new .cmd file, edit it, paste in your typical modification and save it. Then just double click that when needed.
Comment by Aaron Saberan
3 May 23, 2007, 2:40 pm o'clock |
Having a little trouble with this. You created it for me on Experts Exchange (Username is JosephGreenwald-which is my company name). Anyway, it doesn’t seem to work properly. I try to run it (pasted it in a text document, changed the OU to my desired OU name, renamed to .vbs). I get prompts telling me that “You Must specifiy the target OU…….” then I click OK, then I get “And Disable the Syntax Like this:……..”, click ok, then I get a blank message with just an OK button, then I get “modmbxperms.vbs /ou:”"GP Testing Only”" /warn:800 /nosend:900 /disable:1000″ and click OK. Then it goes away (after telling me I must be logged in as an Admin) and it doesn’t seem to ever work. As you can see, I changed the warning to 800, no send to 900 and disable to 1000 as I didn’t know if it was bytes, kb, mb, etc. This was just a test account so I didn’t care if it got locked out. Can you help? Thanks!
Comment by Stacy
2 May 2, 2007, 8:22 am o'clock |
Thanks for the heads up on the code blocks. FUBAR as well on IE 7. Not sure whats up with that.
One word on why I wrote that “Standard Edition!” Ok, two words. Standard edition can’t have more than one mbx store. Get off your enterprise butt sometime!
How are things up in mid town? Down here, they are asking us to fill out this air quality report, on the first day where the Smog is actually at warning levels for sensitive groups!
Comment by Todd
1 April 30, 2007, 2:52 pm o'clock |
Stacy,
Why write this one? Just create another store!
PS, your code blocks are FUBAR on FireFox!
T