Import Users Into Active Directory

By | October 12, 2015

Being a managed cloud provider we get to move and or upgrade Dynamics CRM environments from our customers into our cloud infrastructure. Many of these environments have anywhere from 10 to more than 100 users.

The import will always require the adding of the users in the customer’s environment to the active directory in one of the servers we setup to host the new customer cloud environment.

Every time we have more than 10 users it would be too cumbersome and tedious to add every single user to the active directory therefore we had to opt to do it as a bulk process.

List the CRM users


CRM enabled users.

The first thing we do as we start the migration is to obtain from our customer two lists that we always request to be exported as an Excel file. One is a list with all the enabled users and the other is a list with all the disabled users. This is a really easy task to accomplish because crm already has two views that provide us with these two types of lists.

In CRM 2015 just go to Settings>Security and select Users. The filter should default to Enabled Users. Select Export to Excel to export the list to Excel.


Excel template

Once we have the list of users in Excel we add them to an Excel template we have prepared and fill out the additional columns such as samaccount which is the user id, and password. The columns in the template are also named after the AD attributes. You can download the template here.

Once the excel sheet we use as a template for the import is filled out we export it’s content to a .csv file. You should be familiar with exporting from Excel but if not all you have to do is to select File>Export>Change File Type and select CSV (Comma delimited) and press Save As.


Excel .csv export

Once your users are exported to a .csv file all you have to do is to use Powershell to import all the users into your Active Directory. We have put together a Powershell script which code we leave here. Feel free to use it or make any changes you need to meet your own needs.




Import-Module ActiveDirectory
$Users = Import-Csv -Delimiter "," -Path "D:\FileZilla\FBDisabledUsers.csv"
foreach ($User in $Users)
$OUName = $User.OUName
$UserPrincipalName = $User.userPrincipalName
$SamAccounName = $User.sAMAccountName
$DisplayName = $User.displayName
$GivenName = $User.givenName
$SN = $
$Title = $User.title
$TelephoneNunmber = $User.telephoneNumber
$Password = $User.password
New-ADUser -SamAccountName $SamAccounName -Name $DisplayName -DisplayName $DisplayName -GivenName $GivenName -Surname $SN -UserPrincipalName $UserPrincipalName -OfficePhone $TelephoneNunmber -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $false -Path $OUName -PasswordNeverExpires $true

Enjoy it!

Drop us a comment or if you have any questions please contact us through our QualTech-Software Solutions or QualTechCloud Integrated Cloud solutions customer form.

Leave a Reply