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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BSonPoshConnect With a Mentor Commented:
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
 
calliemanCommented:
0
 
BSonPoshCommented:
any news here?
0
All Courses

From novice to tech pro — start learning today.