Wednesday, June 20, 2007

Create Bulk Users from TXT File Exchange 2007




In this Example we will create bunch of test users from EMS (Exchange management Shell). I think getting to hang of the shell takes some time and challenge. When we see the power of new EMS, I am sure we all will like it a lot. There are a lot of samples on the web showing how to get this accomplish, I am putting some extra afford to get someone who has never touched EMS yet, and following this article and creating 50 users in 10 seconds. Let's get going step by step how to get this goal done in Exchange 2007.

  • Open EMS (exchange management Shell)
  • Now change your directory to root director (Optional) by typing Desktop>cd /.
  • Press Enter. Now you are on Root directory, Go ahead and type

    Md BulkUsers

    And hit enter (MD is make directory, essentially you are creating a folder from EMS, versus GUI)

    Type CD Bulk* (Change directory to this folder)

All we did so far, creating a folder called BulkUsers and we have changed our directory into this folder. Now type notepad on the EMS (Exchange management Shell) and copy and paste below list into it

Alias,Name,UPN

Web-,Web-,Web-@Smtp25.org

Web-2,Web-2,Web-2@Smtp25.org

Web-3,Web-3,Web-3@Smtp25.org

Web-4,Web-4,Web-4@Smtp25.org

Web-5,Web-5,Web-5@Smtp25.org

Web-6,Web-6,Web-6@Smtp25.org

Web-7,Web-7,Web-7@Smtp25.org

Web-8,Web-8,Web-8@Smtp25.org

Web-9,Web-9,Web-9@Smtp25.org

Web-0,Web-0,Web-0@Smtp25.org

Web-1,Web-1,Web-1@Smtp25.org

Web-2,Web-2,Web-2@Smtp25.org

Web-3,Web-3,Web-3@Smtp25.org

Web-4,Web-4,Web-4@Smtp25.org

Web-5,Web-5,Web-5@Smtp25.org

New-Hires1,New-Hires1,New-Hires1@Smtp25.org

New-Hires2,New-Hires2,New-Hires2@Smtp25.org

New-Hires3,New-Hires3,New-Hires3@Smtp25.org

New-Hires4,New-Hires4,New-Hires4@Smtp25.org

New-Hires5,New-Hires5,New-Hires5@Smtp25.org

New-Hires6,New-Hires6,New-Hires6@Smtp25.org

New-Hires7,New-Hires7,New-Hires7@Smtp25.org

New-Hires8,New-Hires8,New-Hires8@Smtp25.org

New-Hires9,New-Hires9,New-Hires9@Smtp25.org

New-Hires10,New-Hires10,New-Hires10@Smtp25.org

New-Hires11,New-Hires11,New-Hires11@Smtp25.org

New-Hires12,New-Hires12,New-Hires12@Smtp25.org

New-Hires13,New-Hires13,New-Hires13@Smtp25.org

New-Hires14,New-Hires14,New-Hires14@Smtp25.org

New-Hires15,New-Hires15,New-Hires15@Smtp25.org

Sales-1,Sales-1,Sales-1@Smtp25.org

Sales-2,Sales-2,Sales-2@Smtp25.org

Sales-3,Sales-3,Sales-3@Smtp25.org

Sales-4,Sales-4,Sales-4@Smtp25.org

Sales-5,Sales-5,Sales-5@Smtp25.org

Sales-6,Sales-6,Sales-6@Smtp25.org

Sales-7,Sales-7,Sales-7@Smtp25.org

Sales-8,Sales-8,Sales-8@Smtp25.org

Sales-9,Sales-9,Sales-9@Smtp25.org

Sales-10,Sales-10,Sales-10@Smtp25.org

Sales-11,Sales-11,Sales-11@Smtp25.org

Sales-12,Sales-12,Sales-12@Smtp25.org

Sales-13,Sales-13,Sales-13@Smtp25.org

Sales-14,Sales-14,Sales-14@Smtp25.org

Sales-15,Sales-15,Sales-15@Smtp25.org

Save the file into the folder you have created and name it "IT.txt"

Now you are on EMS, copy and paste the following string into the EMS,

$Password=Read-Host "Enter Password" -AsSecureString

Note# if you neglect the – (dash) in front of AsSecureString or not type it at all, you will see the password while you are typing it in the Exchange Management Shell, This might be causing security issues. Also make sure the password meets your complex password requirements otherwise the script will fail with a corresponding error

Enter your Complex password (the password is going to be the same for all the accounts)

Now we are almost ready.

Import-CSV IT.txt | foreach {new-mailbox -alias $_.alias -name $_.name -userPrincipalName $_.UPN -database "SG1-MB1" -org IT -Password $Password}

Now,Couple things above needs to be changed.

  • -database "SG1-MB1"
  • -org IT

SG1-MB1 is in my environment Storage Group one, mail box store one, this is name convention I come up with. In order to figured out what is yours do this on the EMS(exchange management shell)




 

[PS] C:\BulkUsers>Get-MailboxDatabase

As you see below table, I could use any of these in the script above, when you figured out your replace into the script.

Name Server StorageGroup Recovery

---- ------ ------------ --------

SG1-MB1 EXC07 SG1 False

SG2-MB1 EXC07 SG2 False

SG3-MB1 EXC07 SG3 False


 

The second one, where we will be pacing all these users. I have created OU called IT as below and I am going to place all the users in this OU, so Either Create an OU with the same name on your AD or create something else, but don't forget to come back and modify the script.





Now we are ready to copy the script into the EMS and hit enter. If we go back to ADUC and look into the IT , OU we will see all the users listed there, Don't forget if you need to create more users, just open the notepad, CTRL + H ( find and replace) as below Enjoy creating users, in exchange 07. As you see how easy to create bulk users and it is really powerful

Best

Oz ozugurlu

1 comment:

Oz Casey, Dedeal said...

here is the Microsoft link

http://msexchangeteam.com/archive/2006/09/05/428833.aspx


best
oz