How to get records from CSV file and create/update users in Active Directory with System Center 2012 Orchestrator.

In this post i'll let you know how to read data/records from CSV file, retrieve user information from the records, create user or update user information(if already exist) in Active Directory with System Center 2012 Orchestrator.
Here is the overall picture of runbook and input file. 

Input File:

**Runbook:
**

Read Line:
   Provide the file path and type of file encoding of input file. In the Line Number field specify the specific line numbers or range to read the lines. In our case the first line in the input file is header which we'll skip so given the range from 2nd line to END.

Get Records:
Select the script type PowerShell, split the records based on carriage return and populate the records in the array list.


Process Records:
      Split each record based on comma "," to extract user information and populate this information to the variables.

Publish data to access it other activities.

**Get User:
** In this activity check the user in the active directory either it already exist or not. If not exist then create user otherwise update the user properties.

Filter to find user in the active directory is based on First Name.

If User count from the get user activity is equal to 0, it means user not exist so create the user properties.

**Create User:
**Populate the user properties by accessing the published data from the previous activities.

If User count from the get user activity is not equal to 0, it means user already exist so update the user properties.

**Update User:
**Update user based on Distinguished Name, the Distinguished Name will be available from get user activity

Finally run the runbook in the Runbook Tester, after successful completion verify the users in the Active Directory.