How to Import SharePoint Users Using a CSV File

CSV file imageAs a Hosting Provider, we at get asked quite a few questions about moving an environment to our privately hosted cloud, whether it be from another hosting provider or from an on-premises solution.

As I’m sure you can imagine, many of those questions relate to SharePoint, and more specifically, in regards to SharePoint users.

Here’s a few examples of the types of questions we get asked:

  • “Since our new environment with will not be in the same domain as our current environment, how will this affect our SharePoint users?”
  • “I currently have a shared environment with you. How can I move my users to my new dedicated environment?”
  • “I am currently with another hosting provider. Will I be able to move my users over to you?”

Not all of the questions are yes/no, but the answer to a majority of them is, yes. There are many ways to get your users from one environment to another. In this blog, I will show you how you can migrate users from one AD to another by simply using a Comma Separated Value (CSV) file and a command line batch file.

In this particular example, I will move users from an Organizational Unit (OU) in a shared Active Directory domain to their own dedicated Active Directory Domain. Now, there are other ways around migrating users and implementing a Single Sign-On solution using a VPN tunnel, but we won’t get into that at this time.

This post will assume that your users are already in a CSV file, however, I will provide a few ways to do this.

One way to get your users in a CSV file is to right click the particular OU and select Export List. This will export the users in a Tabbed Delimited file, which will be a bit ugly, but can be modified using Microsoft Excel. A second way to do this is by using third-party tools. We actually have a third-party SharePoint migration tool that allows us to connect to a SharePoint site and export the users into a CSV list. The third way, if you don’t have a painful amount of users, is to create a CSV yourself and add the users into Excel on your own.

If you need any assistance with exporting users or creating CSV files, please leave a comment or contact us directly.

Ok, so you have a working CSV file, correct? Good. Now all that is really required is the Display Name, username, OU, and password. If you have any other attributes, that is fine, but those are the four requirements.

Below is an example of a CSV file with a few users, and in the proper format.

Example of CSV file

* If you have a heading row at the top, that must be removed before running the batch file.

Now that you have your users list ready to go, we can now create the command line batch file. To do this, all you need to do is open Notepad and copy the text from below:

@echo offclsfor /f “tokens=1,2,3,4 delims=,” %%A in (TestUsers.csv) do (dsadd user “CN=%%B,OU=%%C,DC=TESTDOMAIN,DC=LOCAL” -display “%%A” -pwd %%D)

Save the Notepad file as CreateADUsers.bat. The *.bat file extension will make it a batch file that can be run from a Windows Command prompt.

Now, there are a few things you will need to change in the above text:

Let’s go through this together. The first part is the “tokens=1,2,3,4”. This is how many columns you have in your user list. Using my example from above, we have 4 columns, so we use “1,2,3,4”. If you added a column for email address, you would have “1,2,3,4,5”, etc.

The second thing you will need to change is the filename in the parentheses. In my example, I am using TestUsers.csv. Please update accordingly.

The third thing to change is the Active Directory domain name. In my example, I am using TESTDOMAIN.local. You can use my example and change as necessary to the proper domain name.

The final thing is to change what column contains what information. As you can see from my screenshot, column A is the Display Name, column B is the username or “CN”, column C is the OU the user account will be imported into, and finally column D is the user’s password.

Update the tags in the batch file to match the layout of your user list. Save your batch file. Make sure that your batch file and user list file are saved in the same location/folder. The OU must be created before running the batch file. The batch file will NOT create the OU if it does not exist.

You are now ready to run the batch file and import the users. This is very simple.

Browse to Start > All Programs > Accessories > Command PromptCommand Prompt

Point the command prompt to the proper location of where your saved files are. I have placed mine in the root of the local drive.

Type the filename of your batch file, and press EnterType filename of your batch file

If all is successful, you should see the following displayed:Successful command prompt

Browse to Active Directory Users and Computers, select the appropriate OU and see your users:Active Directory Users

And that is it! Your users are now created in the new domain.

Needless to say, if you do not have your user’s passwords on file, they will need to change. There is not a way to migrate users between two Active Directories and maintain their passwords OOTB.

Again, please let us know if you need any assistance with migrating users. is happy to help!

2014-01-10T08:45:23+00:00 January 10th, 2014|

Leave A Comment