Solved

Programmatically Provision AD User Accounts and Exchange 2007 mailboxes

Posted on 2013-11-21
3
420 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Junk folder 23 168
Distribution groups exchange 2013 6 55
MS-Access 2002 error (Win XP on Win7Pro) 19 69
Outlook 2012 VBA: Object missing 14 32
New-MailboxSearch Powershell Command and step by step approach to Search and Extract Emails form Exchange 2013 Journaling server.
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques.
Viewers will learn the different options available in the Backstage view in Excel 2013.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

776 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