@footech - Help with existing Powershell script for adding new users into AD.

ChicagoTransplant
ChicagoTransplant used Ask the Experts™
on
@footech - I am actually having trouble with your input to get my script to work.  Based on what you said, I modified my script to look like this:  

Import-Csv .\newusers.csv | foreach { New-ADUser -Name $_.Name -SamAccountName $_.SamaccountName -UserPrincipalName $_.Userprincipalname -GivenName $_.GivenName -Surname $_.Surname -StreetAddress $_.StreetAddress -City $_.City -State $_.State -PostcalCode $_.PostalCode -OfficePhone $_.OfficePhone -MobilePhone $_.MobilePhone -AccountPassword (ConvertTo-SecureString "Windows@123" -AsPlainText -Force) -Enabled $true }

and the attached .CSV file is the input file.  What am I missing?  It keeps telling me that "Import-Csv : Cannot process argument because the value of argument "name" is invalid. Change the value of the "name" ar
gument and run the operation again.
At line:1 char:11"
newusers.csv
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Infrastructure Architect
Commented:
There was a empty column after UserPrincipalName which is causing error as it does not have a valid header. Attached the sample csv..
sample.csv

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial