Create Multiple Domain accounts

Hi EE

I dont need any error checking .. just a quick script to create some accounts , can someone help with the error ?

New-ADUser : A positional parameter cannot be found that accepts argument '.'.
At C:\TESTING\CreateUsers.ps1:3 char:2
+     new-aduser -Name $_.Name `
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.NewADUser

Import-Csv "C:\TESTING\UsersToCreate.csv" | ForEach-Object {
	$upn = $_.SamAccountName + "@myLab.com"
	new-aduser -Name $_.Name `
			   -GivenName $_."GivenName" `
			   -Surname $_."Surname" `
			   -SamAccountName $_."samAccountName" `
			   -UserPrincipalName $upn `
			   -Path $_. "Path" `
			   -AccountPassword (convertTo-SecureString "P@ssw0rd%@1234" -AsPlainText -force):
}

Open in new window

LVL 2
MilesLoganAsked:
Who is Participating?
 
Dustin SaundersConnect With a Mentor Director of OperationsCommented:
-Path $_. "Path" `

Open in new window


Looks like you have a space here.
0
 
MilesLoganAuthor Commented:
I just removed it again and received the same error  .. hmmm
0
 
Dustin SaundersDirector of OperationsCommented:
Just a sec- updating that answer.
0
 
MilesLoganAuthor Commented:
love it ! glad to have an extra set of eyes .. I appreciate the help .
1
 
Dustin SaundersDirector of OperationsCommented:
No problem, good luck with your task!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.