Unable to Import-CSV to AD with New-ADuser

I am having a problem in getting my Import-CSV to work.

Here's my csv data:
"Alex Lupe ","OU=700,OU=employees,DC=west,DC=local","(never)","70007335","0","0","CN=70007335,OU=700,OU=employees,DC=west,DC=local","Alex","Lupe","70007335","70007335","805306368","6/22/2004","144","west.local/Users,"OU=700,OU=employees,DC=west,DC=local","H:","4","CN=Person,CN=Schema,CN=Configuration,DC=west,DC=local","top;person;organizationalPerson;user","513","66048","70007335"

My script is pretty straight forward I thought:

Import-Csv C:\AD_Import\ActiveEmployees.csv | ForEach-Object {
        -Name $_.name
        -GivenName $_.givenName
        -Surname $_.sn
        -accountpassword (ConvertTo-SecureString -AsPlainText $_.userPassword -force)
        -Path $_.path
        -AccountExpires  $_.accountexpires
        -CN  $_.cn
        -codePage $_.codePage
        -countryCode $_.countryCode
        -description $_.description
        -distinguishedName $_.distinguishedName
        -displayName $_.displayName
        -sAMAccountName $_.sAMAccountName
        -sAMAccountType $_.sAMAccountType
        -HomeDirectory $_.homedirectory
        -HomeDrive $_.homeDrive
        -instanceType $_.instanceType
        -objectCategory $_.objectCategory
        -objectClass $_.objectClass
        -primaryGroupID $_.primaryGroupID
        -userAccountControl $_.userAccountControl
        -userPrincipalName $_.userPrincipalName
        -Enabled $True
        -ChangePasswordAtLogon $False

But when I run it, I keep getting:

cmdlet New-ADUser at command pipeline position 1
Supply values for the following parameters:

Been working on this for hours and can not seem to find what is wrong.  Any ideas??
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.

Matthew BorrussoCommented:
While I may not be able to offer specific insight into what is exactly wrong with your particular script, I am attaching a link to a technet blog. This blog has an example of the tools in use with formatting examples of the supporting files. It may not be solution, but it may provide some direction as to how to make it work.

The only real difference is the blog does not use the foreach-object call. Unless there is a particular reason for doing it exactly this way, give the blog method a go.

Good Luck with it,
yo_beeDirector of Information TechnologyCommented:
Are you running this from the Active Directory powershell command shell or start Powershell?

 If you are running this from the standard Powershell did you import the active directory module?

Import-module Activedirectory.
You can't just add line breaks at will. If you want to format a single command over several lines, you need to tell PS that the line continues by adding a backtick ` at the very end of the line.
Import-Csv C:\AD_Import\ActiveEmployees.csv | ForEach-Object {
	New-ADUser `
		-Name $_.name `
		-GivenName $_.givenName `
		-Surname $_.sn `
		-accountpassword (ConvertTo-SecureString -AsPlainText $_.userPassword -force) `
		-Path $_.path `
		-AccountExpires  $_.accountexpires `
		-CN  $_.cn `
		-codePage $_.codePage `
		-countryCode $_.countryCode `
		-description $_.description `
		-distinguishedName $_.distinguishedName `
		-displayName $_.displayName `
		-sAMAccountName $_.sAMAccountName `
		-sAMAccountType $_.sAMAccountType `
		-HomeDirectory $_.homedirectory `
		-HomeDrive $_.homeDrive `
		-instanceType $_.instanceType `
		-objectCategory $_.objectCategory `
		-objectClass $_.objectClass `
		-primaryGroupID $_.primaryGroupID `
		-userAccountControl $_.userAccountControl `
		-userPrincipalName $_.userPrincipalName `
		-Enabled $True `
		-ChangePasswordAtLogon $False

Open in new window

starr8303Author Commented:
I was able to resolve the error and also found that I was trying to load some predetermined values into AD.  Here is what my final script looked like:
Import-Csv C:\AD_Import\ActiveEmployees.csv | ForEach-Object {
        accountpassword=(ConvertTo-SecureString -AsPlainText $_.'userPassword' -force) 


        new-aduser @newemployee

Open in new window

Thank you all for your thoughts!

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
starr8303Author Commented:
Was a combination of reasons that this code was failing.  The other answers focused on syntax, but the answer also involved invalid items trying to import into AD.
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.