Create user with vbs in Exchange 2007

Hi

I have the following vbs code that creates a user in AD and adjoining Exchange account.  This code has worked fine with Exchange 2003, but with Exchange 2007 the Exchange account that is created is of type legacy and does not work.  Help&.
user="nnn"
Set objOU = GetObject("LDAP://cn=users,dc=interconsult,dc=com") 
Set objUser = objOU.Create("User", "cn=" & user)
objUser.Put "sAMAccountName",user
objUser.SetInfo
MailServer="ICGTRD241"
MBXStoreDN ="LDAP://CN=Mailbox Database,CN=First Storage Group,CN=InformationStore,CN=" & MailServer & ",CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=Interconsult ASA,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=interconsult,DC=com"
Set ExchUser = objUser
ExchUser.CreateMailbox(MBXStoreDN)
ExchUser.SetInfo
objUser.Close

Open in new window

cowiekspertAsked:
Who is Participating?
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.

calliemanCommented:
0
BSonPoshCommented:
This is script I used... it takes a csv file for input

Example CSV file
ExternalEmailAddress,Name,Password,UserPrincipalName,FirstName,LastName
Test@domain.com,Test,P@assW0rd!,test@domain.com,Test,Account

Note... you can hardcode the DB Name if you wish.
Param($file,$db = (Get-MailboxDatabase).Distinguishedname,[switch]$whatif)
 
Write-host "Adding Users from File $file"
Write-Host "Using Database $db"
 
if(!(test-path $file)){write-host "$file is not valid file"}
 
$users = Import-Csv $file
 
foreach($user in $users)
{
    $password = ConvertTo-SecureString -String $user.Password -AsPlainText -force
    if($whatif){New-Mailbox -database $db -Name $User.Name -Password  $password -UserPrincipalName $user.UserPrincipalName -FirstName $user.FirstName -LastName $user.LastName -whatif}
    else{New-Mailbox -database $db -Name $User.Name -Password  $password -UserPrincipalName $user.UserPrincipalName -FirstName $user.FirstName -LastName $user.LastName}
}

Open in new window

0

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
BSonPoshCommented:
any news here?
0
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
Exchange

From novice to tech pro — start learning today.