Solved

Programmatically Provision AD User Accounts and Exchange 2007 mailboxes

Posted on 2013-11-21
3
419 Views
Last Modified: 2014-02-21
Hello,

We have an Active Directory 2003 domain running a mixed environment and an Exchange 2007 environment running native 2007.  Our Exchange environment consists of a DB and a CAS server.  We have a HRIS system that we are trying to get to create new users and mailboxes in our AD/Exchange environment automatically.  The system is creating AD accounts correctly but not the associated exchange mailbox.  It ends up creating a mail-enabled user account, not a mailbox user account, so no email mailbox is being generated for the user.  We are currently populating and pushing the following attributes:

cn
department
displayName
extensionAttribute1
extensionAttribute2
givenName
homeMDB
homeMTA
mail
mailNickname
name
-PunicodePwd
sAMAccountName
sn
targetAddress&proxyAddresses
telephoneNumber
title
userAccountControl
userPrincipalName

We are at the point where is it creating a mail-enabled user account but again is not creating an actual mailbox on the server.  Any help pointing us in the right direction would be greatly appreciated.

Thank you,
Paul C.
0
Comment
Question by:adlertech
3 Comments
 
LVL 77

Expert Comment

by:arnold
ID: 39667705
There are many vbscript, powershell scripting examples to fulfill your needs.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39669952
Ideally you just want to disable the mail user using Disable-MailUser and create mailbox for the user using Enable-Mailbox.

The problem you may face will be with the email address.  When you enable mailbox the alias of the account will be same as sAMAccountName. And email address stamped will be based on your email address policy (You can find it under Exchange Management console > Organization Configuration > HUB transport email address policies.).  If you didn't change anything specific on email address policy then email address will be stamped as "<alias>@domain.com".
So If you are sure that your account’s email address are in same format (<alias>@domain.com)then you can use the following code to enable mailbox for users.

To disable users.. create a text file contains the UPN’s of the users which you want to disable.. And use the following code..
GC C:\Users.txt | % {
Disable-MailUser $_ -Confirm:$false
}

Open in new window

C:\Users.txt format
UserA@domain.com
UserB@domain.com
UserC@domain.com
UserD@domain.com

Open in new window

You can use the same input file to enable the mailbox. Use the following code to enable mailbox..
GC C:\User.txt | % {
Enable-Mailbox $_ -Database "Server\Storage Group\DB001"
}

Open in new window

If you have a different email for mat other than (<alias>@domain.com). Then you need to update the correct email address along with the mailbox creation.

Run all the codes from Exchange Management Shell. And also don;t forget to test the code in your test server before you run it against production servers.
0
 
LVL 4

Accepted Solution

by:
aa-denver earned 500 total points
ID: 39669973
This is normal with Exchange 2007.  When a user account is mail enabled all the settings are made in Active Directory but the mailbox is not actually created on the server until the user logs onto the mailbox either with OWA or Outlook or until the user is sent an email.  So program your script to send an email to the new user right after mailbox creation.

A related issue that puzzles people but makes sense after you understand the above is that if you mail enable an account and then mail disable delete that account without connecting to the mailbox or sending mail to the new mailbox, there will be no disconnected mailbox visible on the Exchange server.

This article recaps the situation as well.  http://www.sysadmin-network.com/profiles/blogs/exchange-2007-powershell-1
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 67
How to install USMT 11 85
Instructions for user changing Office 365 OWA password 3 58
Microsoft License Verification Process?? 12 118
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
Easy CSR creation in Exchange 2007,2010 and 2013
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now