Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a great VBscript which will list all my Exchange 2003 mailboxes with a size under a given size.

I have another great VBscript which accepts a list of users and sets the quotas for each of those users.

Can anyone fill in the gap, and point me in the direction of a method (VBscript or otherwise) by which I can set the quota for all users who have a mailbox under a certain limit?

I'm trying to reduce my mailbox limits, and want to start by enforcing that limit for users who are already below it. That way the bigger problem of getting people below the new limit doesn't get any bigger!

Update: Thanks to Evan Anderson I found that I need to convert my GUID to another format for use in an LDAP lookup. Microsoft have a knowledge base article that explains how to do this, but I don't have GUIDs in the required format. There is another kb article that describes "how to convert a string formatted GUID to a hexadecimal string form for use when querying the active directory", but the script throws an error.

Update 2: Ok - forget the VB script. I found a more succinct way to get my data using PowerShell.

$computers = "vexch01","vexch02"
foreach ($computer in $computers) {
  Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $computer | sort-object -desc Size | select-object MailboxDisplayName,StoreName,@{Name="Size/Mb";Expression={[math]::round(($_.Size / 1024),2)}}, MailboxGUID | Export-Csv -notype -Path $computer.csv 

Currently this outputs the MailboxGUID as a string type GUID (e.g. {21EC2020-3AEA-1069-A2DD-08002B30309D}). I want to look up users in AD by this, but AD stores them in octetBytes format.

I have found some powershell functions which will do the conversion but only when the curly braces are removed. The Guid.ToString method should supply this, but I can't get it to work in the above.

However, if I could figure out how to do that, the Guid.ToByteArray method might get me even closer.

Has anyone cracked this?

share|improve this question
up vote 6 down vote accepted

Without seeing your scripts it's difficult to give you a "turn key" solution. You'll probably be able to match up user accounts to mailboxes by doing an LDAP search against the msExchMailboxGuid attribute, depending on whether or not your mailbox size script can return that. That GUID will disambiguously pair a mailbox and AD user account across your entire Exchange organization.

share|improve this answer
I'm now working within an AD/Exchange environment anymore, but you should be able to match up the user's ldap properties. I personally like ADExplorer ( for exploring such things. – gWaldo Aug 24 '11 at 14:45
Thanks for that. The scripts I have use CDOEXM which doesn't seem to include the GUID. However, I found that WMI can be used to get the GUID, so I might be able to knock together a PowerShell script to achieve what I want based on the info you gave, my VBscripts and some judicious use of Google... – dunxd Aug 24 '11 at 16:10
Wow - I've made huge steps towards getting this working thanks to your help. However, the ldap query doesn't use the guid format you can easily extract from the mailboxes - - So I need to write a subroutine to convert from one format to another. I hope there is a good reason this is so tricky :-) – dunxd Aug 24 '11 at 17:03
@dunxd: It's an LDAP-thing. They store the GUID as a binary value so you have to format it as such in your LDAP query string. Loads of fun. Your WMI method is probably better-supported in future versions of Exchange, too. – Evan Anderson Aug 24 '11 at 19:06
Have a look at theConvert-ByteArrayToHexString function on this page:… – Evan Anderson Aug 25 '11 at 19:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.