Creating User AD account from a CSV file

Welcome Forums General PowerShell Q&A Creating User AD account from a CSV file

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 5 months ago.

  • Author
  • #6199

    Topics: 1562
    Replies: 0
    Points: 0
    Rank: Member

    by Dios_007 at 2012-10-24 04:19:52

    Hi All

    If i have a CSV file with the headings First Name, Last Name, Full Name, User Name, Description (Which has been export from Domain A) is there a way i can use powershell to create User accounts in Domain B with this information. The password for all users can be set to Password.

    Account will be created in the Administrative > Accounts OU.

    I normally do this via DSADD but takes a long time to format the data. null

    by Klaas at 2012-10-24 04:32:22

    You can Import-Csv and pipe that to New-ADUser.
    You need to be on a domain controller or a computer with RSAT installed.
    If that's not possible I guess you can do the same with Quest AD-cmdlets, which you can download from their website.
    Another option is to create a loop with [ADSI]'LDAP://' provider but that's a lot more work.

    by Dios_007 at 2012-10-24 05:09:45

    Yes i have access to the domain controller in my test area.

    I have change the headings to have no spaces FirstName, LastName, FullName, UserName, Description (Not sure if i had to do this)

    I have worked out the below so far think its right, how would i go about statiting the default password for all accounts and the OU the accounts will be created in.

    Import-CSV c:\Input.csv | ForEach { New-ADUser -GivenName $_.FirstName -Surname $_.LastName -DisplayName $_.FullName -sAMAccountName $_.UserName -Description $_.Description }

    by Klaas at 2012-10-24 06:21:51

    I can't test this myself, but I believe that if you give the AD property names as header in the .csv, you don't need the foreach, so you can just import-csv yourcsv.csv | new-aduser -AccountPassword "1234" -Path "OU=yourOU,DC=yourdomain,DC=com"
    Please do Get-Help New-ADUser -full | more to read all about the parameters and which accept pipeline input.

    by Ramrod at 2013-02-15 05:24:41

    Just put any string related parameter in a text file and save it as .csv. Put the user information in the lines below.

    Next step:

    import.csv your.csv | new-aduser

    Remember that you can put any non-string parameter [bool,int etc.] after the new-aduser cmdlet.

The topic ‘Creating User AD account from a CSV file’ is closed to new replies.