Avatar of ronenshabtay
ronenshabtay
 asked on

Automating User Mailbox Creation with VBScript

Hi Experts,

Is there a way to create a mail-enabled user account in Windows 2000 with a VB script.
 I wrote a script that creates the account, places the account in the right OU and enabled it.
I can't figure out the mail-enable part.There must be a way to do this all in one script.


Thanks for your help

Ronen
Exchange

Avatar of undefined
Last Comment
DarthMod

8/22/2022 - Mon
nbishop1979

ronenshabtay

ASKER
Thanks for your quick response nbishoop1979,
I am familear with this site (I learn a lot on VBScript from it) but I don't want to do it with CSVDE or Excel.
I just want someone to execute the script and the user account will be complete (user enable, password, mail enable etc')

nbishop1979

Microsoft has an article about doing...maybe it would be of some help
http://support.microsoft.com/default.aspx?scid=kb;en-us;327079&Product=exch2003
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
kristinaw

ronen,

are you still seeking a solution to this? i can help out with some vbscirpt code if you still need it.

kris.
ronenshabtay

ASKER
Kristinaw,

I manage to write a code that do the job (following is a copy of it) but I will be very hapy
if you could look at it an post your comments or share me with your own codes. I willing
to give the points  for useful comments or codes.

Ronen

here is my code:

' VBScript to create an OU called QA38Users
' VBSCript then creates, enable and creates mailbox
' to xx Users in OU QA38Users
' ===============================================

Option Explicit
Dim objRoot, objDomain, objOU, objContainer, objUser, objRootDSE
Dim strContainer, strLastUser, strName, strDNSDomain, intCounter, intAccValue, intUser
Dim account, mbxDN, exchUser, objLeaf

strName ="TestUser"

Set objRoot = GetObject("LDAP://rootDSE")
Set objDomain = GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))

Set objRootDSE = GetObject("LDAP://rootDSE")
Set objOU=objDomain.Create("organizationalUnit", "ou=QA38_Test_Users")
objOU.Put "Description", "QA38 Domain Users"
objOU.SetInfo

Set objContainer = GetObject("LDAP://OU=QA38_Test_Users," & _
objRootDSE.Get("defaultNamingContext"))

For account = 1 To 20
Set objLeaf = objContainer.Create("User", "cn=" & strName & account)
objLeaf.Put "sAMAccountName", strName & account
objLeaf.SetInfo
intUser = intUser +1
Next

WScript.Echo intUser & " Users created "

Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strContainer = "OU=QA38_Test_Users,"
intAccValue = 512
strContainer = strContainer & strDNSDomain
set objOU =GetObject("LDAP://" & strContainer )
intCounter = 0
For each objUser in objOU
If objUser.class="user" then
objUser.Put "userAccountControl", intAccValue
objUser.SetInfo
intCounter = intCounter +1
strLastUser = objUser.Get ("name")
End if
next
WScript.Echo intCounter & " Accounts Enabled. Value " _
& intAccValue

mbxDN = "CN=Mailbox Store (QA-41),CN=First Storage Group,CN=InformationStore,CN=QA-41," & _
        "CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=QA38," & _
        "CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=qa38,DC=xosoft,DC=com"
For account = 1 To 20            
Set exchUser = objContainer.Create("User", "cn=" & strName & account)  
exchUser.CreateMailbox mbxDN
exchUser.SetInfo
intUser = intUser +1
Next

WScript.Quit
kristinaw

No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
PAQ - Points Refunded

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

kristinaw
EE Cleanup Volunteer
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
DarthMod

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.