---
title: "Import Users in Active Directory with PSADSync"
description: "Easily import users in Active Directory using the free AD sync PowerShell module, PSADSync."
canonical: "https://adamtheautomator.com/import-users-active-directory/"
---

# Import Users in Active Directory with PSADSync

> Easily import users in Active Directory using the free AD sync PowerShell module, PSADSync.

Source: https://adamtheautomator.com/import-users-active-directory/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Import Users in Active Directory with PSADSync](https://adamtheautomator.com/wp-content/uploads/2019/07/photo-1523962389844-25940ebd2226.jpg)

# Import Users in Active Directory with PSADSync

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)26 July 20192 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Active Directory](/tag/active-directory/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Setting Up](#setting-up)
*   [Running the AD Sync PowerShell Tool](#running-the-sync)
*   [Summary](#summary)

If you need to import users in an Active Directory domain, you’ve come to the right blog post. No more using Active Directory Users and Computers. In this post, you’re going to use how to use PowerShell to read a CSV file and not only create users but also sync AD attributes with user accounts in the CSV file.

If you look around the web, you’ll find countless PowerShell scripts and snippets to import users into Active Directory. You’ll either find expensive commercial tools or dinky scripts. To prevent this, I’ve built a PowerShell module called [PSADSync](https://www.powershellgallery.com/packages/PSADSync/1.2.88).

The PSADSync PowerShell module takes care:

*   reading CSV files (or even databases)
*   collecting all the necessary attributes
*   finding a matching user in Active Directory
*   populating the necessary user attributes or even creating a new one

## Setting Up

To set things up, open up your PowerShell console and install the PSADSync module.

```powershell
Install-Module PSADSync
```

The only requirements are that PowerShell v4 is installed, you have rights in Active Directory to make attribute changes to user accounts and the computer that the tool will be running on is a member of Active Directory.

The module uses the [ActiveDirectory module](https://adamtheautomator.com/powershell-import-active-directory/) but it will download and install it for you if you don’t have it already.

**_Related: [How to Install the PowerShell Active Directory Module](https://adamtheautomator.com/powershell-import-active-directory/)_**

Once you’ve got the module installed, it’s time to gather up that CSV file full of employee information you’d like to sync to Active Directory.

Below is the CSV file I’ll be working with. It has three employees in it represented by their first name, last name and their internal employee ID from some HR source.

```powershell
FirstName,LastName,EmployeeNumber
Adam,Jones,1
Bob,Baker,2
Sherry,Risley,3
```

I’d like each employee in this CSV file to have the exact same first and last name represented in AD. This is one of the first steps in our AD sync PowerShell tool.

But first, I need to find a match between a CSV row and a single AD user account. To make this match, I’ll need a unique identifier. For this instance, I have an employee number. In AD, this is represented by the `EmployeeId` field. The tool will use this to make a 1:1 match.

I define this matching by mapping the CSV `EmployeeNumber` field to the AD `EmployeeId` attribute using a PowerShell hashtable.

```powershell
$fieldMatchMap = @{ EmployeeNumber = 'EmployeeId' }
```

Next, I need to map each of the CSV fields with the an AD field to tell the tool which CSV fields match up to which AD attributes. I’ll do this again by creating another hashtable.

Notice that the key value in the hashtable is the CSV field and the value for each key/value pair is the AD attribute to check and change, if necessary.

```powershell
$fieldSyncMap = @{
    FirstName = 'givenName'
    LastName = 'sn'
}
```

Now that we have everything mapped correctly, you’re one step closer to importing users in Active Directory! Now ensure the AD user objects are different than what they are supposed to be.

You can see below that none of them have a `GivenName` or a `Surname` attribute. When we’re done, these accounts should match what’s in the CSV fields.

```powershell
PS> 1,2,3 | foreach { Get-AdUser -Properties EmployeeId -Filter "EmployeeId -eq $_" } | select employeeId,givenname,surname

employeeId givenname surname
---------- --------- -------
1
2
3
```

## Running the AD Sync PowerShell Tool

Now run the tool. Running _PSADsync_ is done using the `Invoke-AdSync` command. I’ll use the hashtables I just built to pass to `Invoke-AdSync` as well as specifying the location of the CSV file I’ll be using.

```powershell
PS> $fieldMatchMap = @{ EmployeeNumber = 'EmployeeId' }
PS> $fieldSyncMap = @{
        FirstName = 'givenName'
        LastName = 'sn'
    }
PS> Invoke-AdSync -FieldSyncMap $fieldSyncMap -FieldMatchMap $fieldMatchMap -CsvFilePath 'C:\Employees.csv'
```

Now we’ll do another check to ensure all of the attributes have been populated.

```powershell
PS> 1,2,3 | foreach { Get-AdUser -Properties EmployeeId -Filter "EmployeeId -eq $_" } | select employeeId,givenname,surname

employeeId givenname surname
---------- --------- -------
1          Adam      Jones
2          Bob       Baker
3          Sherry    Risley
```

## Summary

This was just an intro to syncing AD with PowerShell. The PSADSync module supports many different scenarios and has an extensive suite of Pester tests. It _should_ be able to support just about whatever kind of syncing you’d like to do!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fimport-users-active-directory%2F&text=Import%20Users%20in%20Active%20Directory%20with%20PSADSync)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fimport-users-active-directory%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fimport-users-active-directory%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2024/11/image-23.png)

### [Managing Active Directory Groups with PowerShell: The Ultimate Guide](/powershell-ad-groups-guide/)

Learn how to manage Active Directory groups with PowerShell! This hands-on guide shows you how to query, create and modify AD groups using practical real-world

![](https://adamtheautomator.com/wp-content/uploads/2019/08/database-152091_1280.png)

### [Active Directory Database: PowerShell Monitoring Made Easy](/active-directory-database/)

Find the ntds.dit location and monitor your Active Directory database using PowerShell.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/panic-1393619_1280.png)

### [How to Find Locked Out Users in Active Directory with PowerShell](/find-locked-out-users-in-active-directory-powershell/)

See what we can do to find locked out users in Active Directory with PowerShell!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
