Solved

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

Posted on 2012-12-21
1
282 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

730 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