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=A lumwell 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=A lumwell 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?
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=A
$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=A
$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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.