Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

exchange 2010 - Scripts to create users

Posted on 2010-01-08
9
Medium Priority
?
2,717 Views
Last Modified: 2012-06-21
We are looking for a bulk way to create users, and also automate it by reading from a csv or other file.

We have found some good resources for doing this with 2007, but they do not seem to work properly in 2010.  Anyone have a working base script we could alter, or know a good site that does?
0
Comment
Question by:TacoFlavoredKisses
  • 3
  • 3
  • 3
9 Comments
 
LVL 1

Author Comment

by:TacoFlavoredKisses
ID: 26214437
We did not.  Looking at this now.  
0
 
LVL 9

Expert Comment

by:tl121000
ID: 26214592
Definitly works for past Exchange Version 2003.
Caveats-
  • you need to create the GPO that the user will reside in prior to import process GPO
  • I have often had to change the default domain password policy to 0 character 0 complexity , for the account creation process.  After the process is complete turn it back on.
  • You can reset all user passwords to generic at once - select all new accounts in ADUC - right click propeties - change password for all
    I actually refer to this tutorial often >>> http://www.computerperformance.co.uk/Logon/Logon_CSVDE.htm
    exchange attirubutes>>>http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.htm
     
    0
    Creating Active Directory Users from a Text File

    If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

     
    LVL 58

    Expert Comment

    by:tigermatt
    ID: 26214850

    It's funny you should ask this as it caught my attention. I am in the process of constructing a blog post/EE article on Exchange 2010 administration automation as we speak!

    Your best bet in 2007 and 2010 is the use of a Powershell script rather than CSVDE. This will ensure the user account and the mailbox is created inExchange. I'm attaching a Powershell script I've just drafted and tested for you to do this. Please feel free to modify this as necessary to achieve the desired effects for your organisation.

    At present, the script expects the CSV format to be as per the following example. The first title line is also required.

    "Name","Username","Forename","LastName","Password"
    "Test User 1","Testvfjvfj1","Test","User","12345"
    "Test User 2","Testifbjbf2","Test","User 2","123"

    If you wish to modify the script, you would probably want to start by looking up the commands available to you in the New-Mailbox cmdlet: http://technet.microsoft.com/en-us/library/aa997663.aspx.

    -Matt
    Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -ea silentlyContinue
    
    # Import the CSV file - modify the path to your file here
    $csv = Import-CSV "C:\csv.csv"
    
    # The OU and domain to import the user accounts to 
    $ou = 'domain.local/Business/Users/Management/Standard'  
    
    # Your domain name
    $domain = 'domain.local'
    
    # Mailbox Database to create mailboxes in (format is server\StorageGroup\Database Name)
    $database = 'SERVER\StorageGroup\Database'
    
    # Loop through the CSV and create a new user & mailbox for each line found
    foreach ($mbox in $csv)
    {
      $upn = $mbox.username+'@'+$domain;
      $password = ConvertTo-SecureString -AsPlainText -Force -String $mbox.password
    
      # Create mailbox - this command will print an error to the Powershell window, but continue processing in the event of an issue arising
      New-Mailbox -Name $mbox.name -Alias $mbox.username -OrganizationalUnit $ou -UserPrincipalName $upn -SamAccountName $mbox.username -FirstName $mbox.forename -LastName $mbox.lastname -Password $password -Database $database -ea Continue;
      
    }
    

    Open in new window

    0
     
    LVL 9

    Expert Comment

    by:tl121000
    ID: 26215397
    TigerMatt - definitely more flexible and streamlined...
    0
     
    LVL 1

    Author Comment

    by:TacoFlavoredKisses
    ID: 26248693
    Looks great.  We will be testing this out Monday and will get back to you with the results then.  Thank you.
    0
     
    LVL 58

    Accepted Solution

    by:
    tigermatt earned 2000 total points
    ID: 26272546

    Sorry, I just discovered a slight issue with the script.

    When you test, try the below.

    -Matt
    Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010 -ea silentlyContinue
    
    # Import the CSV file - modify the path to your file here
    $csv = Import-CSV "C:\csv.csv"
    
    # The OU and domain to import the user accounts to 
    $ou = 'domain.local/Business/Users/Management/Standard'  
    
    # Your domain name
    $domain = 'domain.local'
    
    # Mailbox Database to create mailboxes in (format is server\StorageGroup\Database Name)
    $database = 'SERVER\StorageGroup\Database'
    
    # Loop through the CSV and create a new user & mailbox for each line found
    foreach ($mbox in $csv)
    {
      $upn = $mbox.username+'@'+$domain;
      $password = ConvertTo-SecureString -AsPlainText -Force -String $mbox.password
    
      # Create mailbox - this command will print an error to the Powershell window, but continue processing in the event of an issue arising
      New-Mailbox -Name $mbox.name -Alias $mbox.username -OrganizationalUnit $ou -UserPrincipalName $upn -SamAccountName $mbox.username -FirstName $mbox.forename -LastName $mbox.lastname -Password $password -Database $database -ea Continue;
      
    }
    

    Open in new window

    0
     
    LVL 1

    Author Closing Comment

    by:TacoFlavoredKisses
    ID: 31674791
    Script is working well.  Thank you.
    0
     
    LVL 58

    Expert Comment

    by:tigermatt
    ID: 26286172
    Great news. Thanks!
    0

    Featured Post

    VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

    Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

    Question has a verified solution.

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

    Among the most obnoxious of Exchange errors is error 1216 – Attached Database Mismatch error of the Jet Database Engine. When faced with this error, users may have to suffer from mailbox inaccessibility and in worst situations, permanent data loss.
    Welcome to 2018! Exciting things lie ahead in the world of tech. To start things off, we compiled great member articles on how to stay safe, ways to learn, and much more! Read on to start your new year right.
    To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
    Screencast - Getting to Know the Pipeline
    Suggested Courses

    564 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