Solved

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

Posted on 2012-12-21
1
283 Views
Last Modified: 2012-12-27
@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
0
Comment
Question by:ChicagoTransplant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38714082
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
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question