Create users using CSV and Powershell

There have been a lot of questions on the internet about how to create users from csv so I wondered if I could just create a quick simple guide how to do this. First we need to decide what attributes we are going to implement into the CSV file, we need some required attributes such as First Name, Last Name, Display Name, Username and so on. You can run the following command to see what attributes you can add or modify to the user, in this example I will just use Administrator

These are the attributes in this scenario which I am going to use in the script

  • Surname – The last name of the user or the family name
  • FirstName – Given name
  • DisplayName – Full name
  • SamAccountName – Username
  • Name – Full name
  • AccountPassword – User Password
  • Path – Path where the user should be placed
  • Enabled – If the user should be enabled or disabled
  • UserPrincipalName – The UPN or would be something like user@domain.com
  • ProfilePath – Where the profile data should be placed, use UNC path
  • HomeDirectory – UNC path where the user can save their data to
  • Department – The department
  • HomeDrive – Driveletter for the HomeDirectory

We start by creating the CSV file, create a file name Users.csv in a folder named C:\UserCreation folder on the server where the RSAT tools are installed or on the Active Directory controller. We will create two users in this example

You probably noticed that the CSV file does not contain all the property parameters which I mentioned above, that is because I´m going to auto build some of the property values using the script. Here is the script to build a user.

Note if you are going to add some extended attributes you can use the following property in the New-ADUser command, you can place variables in the values for the attribute.

Hope you can use this 🙂

Trackback from your site.