In the first article, we created a user in Server 2008 with PowerShell. In this article, we will explore how to create more users in Server 2008 with PowerShell. First, open the PowerShell prompt and type New-User -Name “MyNewUser” -Passwd “MyNewPassword” . This will create a new user named MyNewUser with the given password. Next, open the Users folder and type New-User -Name “MyNewUser2” . This will create a new user named MyNewUser2 with the given password. Now that you have two users in Server 2008, it is time to add them to an organization. To do this, open the Organizational Unit (OU) Manager and click on the Add button. Type MyNewUser into the Name field and click on OK. The OU Manager will add MyNewUser2 to the organization.


In this case, we’ve been given the Office attribute for our new users, so we’ll want to make sure that’s added in each of our new users account on creation.

The first thing we do is to save the excel file as a .csv file.

Next we open up the Active Directory Users and Computers snap-in. We need to find out what is the actual attribute name for the Office field, so we’ll open the properties of one of our current users by double-clicking on them.

We can see that this user has Human Resources filled in for his Office attribute on the General tab.

We’ll click on the Atribute Editor tab to find out the technical name for that Office field, because we are going to need this to enter into PowerShell in a minute. It shows that the Attribute name for the Office field is physicalDeliveryOfficeName. Since the Attribute name is not always the same as the Field name in the other tabs, it can be a little difficult sometimes to find what you are looking for. If you can’t seem to find the field you need, you can always create a dummy user and modify just that specific field to something unique, then go to the Attribute Editor tab and scroll down until you find it.

Now we’ll need to edit our PowerShell script to reflect this new field. The format for this will be “AttributeName=dataRecord”. We want to make sure that we enter the field name correctly from our .csv file after the “$dataRecord.” entry. This section will pull the data from our users file:

and this section of the script will put it into the new user objects:

The finished script will look like this:

Make sure to save the script as a .ps1 file.

With our users list and our script in the C:UsersAdministrator folder, we right-click the script and choose Run with PowerShell.

When we jump back over to AD Users and Computers, we can see out new users created.

Opening up one of our newly created users will show that the Office field is filled out with the data from our original users list.

Creating multiple users with PowerShell is a very easy task, and with this knowledge at your fingertips, you’ll never sweat it again.