VBSCRIPT - Creating a mailbox in the same store as another named user's mailbox

I already have a script that creates a new AD user, enables it, sets the password and then copies the group membership from another named user.

I now want to create a mailbox in the same mailstore as that named user. This is so that I can use this on a range of different servers and as long as I have an existing user to copy, it will work without too many parameters having to be filled in.

I therefore want to find the LDAP string of the mailbox of this existing user and then use it to create the mailbox for my new user.

namedUser = WScript.Arguments(0) ' my existing userID

' I need to find the details below for the namedUser

strStore = strStore & "CN=" & strStoreName
strStore = strStore & ",CN=" & strStorageGroup
strStore = strStore & ",CN=InformationStore"
strStore = strStore & ",CN=" & strServer
strStore = strStore & ",CN=Servers"
strStore = strStore & ",CN=" & strAdminGroup
strStore = strStore & ",CN=Administrative Groups"
strStore = strStore & ",CN=" & strExchangeOrg
strStore = strStore & ",CN=Microsoft Exchange"
strStore = strStore & ",CN=Services"
strStore = strStore & objRootLDAP.Get("configurationNamingContext")

'Create and enable my new user - objUser - this already works

' Create a Mailbox for the User

objUser.CreateMailbox strStore

Open in new window


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erik PittiCommented:

It's much easier than you think.

'Get Message Store DN for existing user
strStore = existingUser.Get("homeMDB")

' Create a Mailbox for the new User

objUser.CreateMailbox strStore

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leapconsultingAuthor Commented:
That's great - thank you for your help!

Works perfectly on Windows Server 2003 - doesn't seem to work on 2008. Is there any way of making that work? I want to keep the same solution for both types of server if possible, therefore not Powershell for 2008.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.