, , ,

Hello Everyone,

While Importing an Organization in CRM through Deployment Manager from Live to Test environment(or vice-versa), then before mapping the users we need to first create the users in AD.

Creating a user one by one under an Organizational unit in AD may be frustrating when the count of users are more. But with the help of the PowerShell-Script we can do it within few minutes and save a lot of time.

  • Import Users with First Name, Last Name from the Organization using Advanced Find feature.

  • We’ll save this Excel sheet as an .csv file.

  • Now we’ll create a text document with the following script:

$dataSource=import-csv “ADusers.csv”
foreach($dataRecord in $datasource) {
$cn=$dataRecord.FirstName + ” ” + $dataRecord.LastName
$sAMAccountName=$dataRecord.FirstName + “.” + $dataRecord.LastName
$displayName=$givenName + ” ” + $sn
$userPrincipalName=$sAMAccountName + “@crm.com”

  • The Text Document will look something like this :

Don’t forget to change the Organizational Unit, Domain Name and the saved user excel sheet name  in the Script.

  • Alter the format of script for display name,etc according to the requirement. Then  save the Text Document as .ps1

  • We now have to make some changes to PowerShell, so we’ll open it directly from the shortcut in Taskbar.

  • We need to change the Execution Policy to allow the script to run Remotely, so we’ll type:

” set-executionpolicy remotesigned ”

and type “Y” when prompted.

  • Now we’ll place both the files on the Desktop or in the root folder of Administrator and then right click on PSusersScript.ps1 and select “Run with PowerShell”.
  • If we take a look in the AD Users and Computers then we’ll find the users just created through Script using the Excel sheet.

  • We can now select all the newly created users and edit their properties for password altogether.

The users are now ready to be mapped while importing organization in CRM.

Save both the files so that next time when you create users in bulk, then you’ll only need to change the user data in Excel Sheet and with just a click u’ll be creating users in AD.

Hope this post will be a great time saver!!!