Powershell script to import users to Active Directory Server 2008

Anyone have a powershell script that will import users into Active Directory on a 2008 Domain via ,csv file.

I exported these users to a CSV file from another server, So i just need the powershell script to import from the csv file.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can use the MS ad cmdlets or Quest free AD cmdelts. Depending on what attributes you what to populate. Here is an example of something you could do

¿Foreach ($User in (import-csv C:\Scripts\QAD_User_Import.csv)){
        $QADUserprops = @{
            FirstName = $User.FirstName
            LastName = $User.LastName
            City = $User.City
            PhoneNumber = $User.PhoneNumber
            StateOrProvince = $User.StateorProvince
            Name = $User.Name
            PostalCode = $User.PostalCode
            UserPrincipalName = $User.UserPrincipalName
            samaccountname = $User.samaccountname
            ParentContainer = "OU=POSH_GROUP,DC=Devlab,DC=Local"
            UserPassword = "PGHPoshPass1"
            DisplayName = $User.Displayname
            Description = $User.Description
            Office = $User.Office
            email = $User.email
    $EmployeeID = $User.EmployeeID

    New-QADUser @QADUserProps -ObjectAttributes @{employeeID=$employeeID}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You can check the following link to use csvde to import user in AD.

MarkolongAuthor Commented:
The top example is the script assuming im already in the import active directory module?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

the one I posted is using the Quest cmdlets. So you will need to add

add-pssnapin *Quest*

if you want an exmaple using the MS cmdlets I can post
Here is an example using MS cmdlets.

import-module ActiveDirectory
$Pass = ConvertTo-SecureString "PoshPass1" -AsPlainText -Force
Foreach ($User in (import-csv C:\Scripts\MS_User_Import.csv)){
    $Userprops = @{
        GivenName = $User.GivenName
        Surname = $User.SurName
        City = $User.City
        OfficePhone = $User.OfficePhone
        State = $User.State
        Name = $User.Name
        PostalCode = $User.PostalCode
        UserPrincipalName = $User.UserPrincipalName
        samaccountname = $User.Samaccountname
        path = "OU=POSH_GROUP,DC=Devlab,DC=Local"
        AccountPassword = $Pass
        enabled = $TRUE
        country = $User.Country
        DisplayName = $User.DisplayName
        Description = $User.Description
        Office = $User.Office
        email = $User.Email

    $EmployeeID = $User.EMployeeID

    New-ADUser @UserProps -OtherAttributes @{employeeID=$EmployeeID}


Open in new window

yo_beeDirector of Information TechnologyCommented:
I know this is a powershell question, but about about using somthing like csvde -i  
This is free and it is part of windows.
Malli BoppeCommented:
I have used csvde in the past and is really  easy to use.


or you can use Admanager which has 30 day license. can be used to set  password as well. I have use in the past and works really well

MarkolongAuthor Commented:
Does all of these solutions work for importing computers as well and other objects
Are you doing a domain migration?

If you are take a look at ATMT

You can create new computer objects with new-adcomputer or new-qadcomputer

Groups using new-adgroup and new-qadgroup
Malli BoppeCommented:
I don't think so .You need to readd them to domain
yo_beeDirector of Information TechnologyCommented:
You can export a template by filtering to a user distinguishedName.  review to the csv file for all your attributes and if you can confirm that they are all available for an import I think you are good then.

 csvde -m -f OUTPUT.CSV  -b USERNAME DOMAINNAME *-s SERVERNAME -d "cn=users,DC=DOMAINNAME,DC=Microsoft,DC=Com" -r "(objectClass=user)"
I have an example of how to do this on the main page of my blog:

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.