Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2012-12-21
1
Medium Priority
?
285 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Here's a look at newsworthy articles and community happenings during the last month.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

618 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