Creating user accounts from a CSV file in Powershell

Hi Im getting an error while creating users from a csv file in PS. The file path is pointing to the correct location in c:\dirve. I’m not sure what’s wrong.

Update: I added the " } " like it said below and I received more errors, so that didn’t fix it.

1 Like

Hi, it will be useful (for helpers) to send screenshot of new errors.

2 Likes

Zoltan, this is the error I receive when using the closing curly bracket.

1 Like

Hi, I cannot see line #5 but believe it should be as follows:
$filepath = Read-Host -Prompt “path of CSV file”
I found it easier to put the CSV file on the desktop then point to it there. Make sure it is in the quotes (" ").
Also don’t make the mistake of selecting your computer desktop drive instead of the LAB desktop if that is where you are trying to create the script.
Hope this helps

1 Like

I changed the file path and ended up getting more errors.

1 Like

Hi Raul,
the error messages are very helpful!!
Let’s see: ERROR “At line:5 char:13”
And really, in line:5 should be (As William wrote above) : $filepath = Read-Host -Prompt “path of CSV file” , but you typed Read Host, with a space character not the “-” . There is no Read command, there is Read-Host command in Powershell.
Don’t be discouraged, I worked with this LAB for 4 hours until I fixed all my mistakes. It was later revealed that there is a different Domain written in the OU section of attached CVS file than should be in the LAB. So the CVS file still needs to be corrected e.g. In Wordpad.
Sorry for bad English :slight_smile:
Zoltan

2 Likes

@zoltan.cseke Nice job!

Thanks Zoltan, I got rid of a lot of errors after an 1.5 hrs. There are still a couple errors I’ve encountered.I also noticed that although I’m pointing to the correct CSV file, it automatically tries to access a ps script saved on my desktop. Missing expression error|690x466

1 Like

Hi Raul, don’t give up!

If your screenshot is actual - You not corected the PREVIOUS error in the 5th row: Read Host instead of Read-Host .
If you correct this typo in the text, and ONLY after yo correct this - we/you can go further!
Zoltan

1 Like

Hi Zoltan, I did get further this time, but once I enter the path to my csv file I get multiple errors. I’ve attached 3 screen shots.
thanks for working with me on this issue.(upload://t9cKYD55piz4Hhb7hjMHv1xrSEj.png)

1 Like

Hi Raul - I think I need to come up with a better way to share code. Screenshots are not good enough.

But back to your issue - “Server is unwilling to process the request” usually means your OU Path is wrong. Looking at your NewUser89 file, your OU path includes the domain name:

DC=ServerAcademy,DC=local

This means your domain name should be serveracademy.local. Is this correct?

To verify the OU paths are correct, open Active Directory and enable Advanced Features:

image

Next right-click your desired OU and go to the attributes tab. Look for the Distinguished Name and copy the value. Compare that value to what you have in the spreadsheet.

Hope that helps.

Paul

Thanks Paul, I was able to get it to work finally

1 Like

Ok great. Was the OU path wrong?

Actually the OU path was correct, It was the csv location I had entered In $filepath = Read-Host -Prompt " please enter the path to the CSV file" kept pointing to the wrong file and causing an error. Once I removed it and entered when it prompt me then it worked, although I could still see errors. All users were created though.

1 Like