Link to home
Start Free TrialLog in
Avatar of alumwell
alumwell

asked on

Importing a CSV file into AD using Powershell

Hello,
I am working on a script to import users into AD from a CSV file via PowerShell. Now the following code works:

$OuDomain = "OU=Teachers,OU=Staff,OU=Alumwell Users,DC=Alumwell-s"
$Csv = "c:\importfile.csv"
# Update details. Add/remove depending on which details to update.
import-csv $Csv | where {new-QADUser -ParentContainer $OuDomain -name $_.name -sAMAccountName $_.sAMAccountName -description $_.description -givenName $_.givenName -SN $_.SN -displayName $_.displayName; enable-QADUser $_.name }

However, when I add the "ProfilePath" attribute, an error is thrown on the console " A parameter cannot be found that matches parameter name 'ProfilePath'"

code:
$OuDomain = "OU=Teachers,OU=Staff,OU=Alumwell Users,DC=Alumwell-s"
$Csv = "c:\importfile.csv"
# Update details. Add/remove depending on which details to update.
import-csv $Csv | where {new-QADUser -ParentContainer $OuDomain -name $_.name -sAMAccountName $_.sAMAccountName -description $_.description -givenName $_.givenName -SN $_.SN -displayName $_.displayName -ProfilePath $_.ProfilePath; enable-QADUser $_.name }

The CSV file contains all the correct headers and does not contain any empty details/columns etc, as I know that can sometimes cause an error. Any ideas?
Avatar of RickSheikh
RickSheikh
Flag of United States of America image

Can you to create one test user from your CSV without the "profilepath" ? For some odd reason I also think if I did what you are doing, I would replace the "where" with "foreach".
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial