Creating user accounts from a CSV in Powershell

When I created the powershell script to create a user from CSV file I get this error when I run the script

1 Like

Is that the full file path or just the directory? Please show me what the $filePath variable equals. I have seen this error before when you try to import a CSV but don’t specify a file name.

I moved the file to the C drive. .

#this is how the csv file looks when you open it

file Path with error

1 Like

You typed CVS not CSV. The convenience store is messing you up, ha!

2 Likes

I get the script to work without -Path $user.“Organizational Unit”
I have tried:
-Path $user.“Organizational Unit”
-Path $user.‘Organizational Unit’

without it is working fine. Why?

The moving part is also giving an error.

The syntax in your first screenshot appears to be incorrect. Don’t just pass the “-”, you need to pass “-path”.

For the second screenshot, verify that your path does exist.

1 Like

It works now :slight_smile: Thanks for the help.

1 Like


Based on the script, which seems to be correct, any idea why It won’t run and I get the error message in the screenshot?

Hi @bigword,

There might be an issue with the file contents and the script that was written. Can you share the script to check on the lab?

It seems is an issue in the CSV for the distingushedName attribute.

Try to see if replacing the one in the cdv file from the desktop with the following works:

Ricardo

Hi @ricardo.p can you please help me here i tried creating new AD users using PS script same as what you did in your video here is the screen Shot … the command seem to be working but am not

see the listed names as is should be same in ur video … ALL i see is that the script worked

am not sure what’s going here please A



dvice / help accordingly

Hi @etinosa4good

It seems that under the section #Import the CSV as an array the $user variable needs to be $users (in plural) otherwise the script will do nothing as in the screenshot. I tested your script in the lab and got the same issue.

Ricardo

hi , am having another issue again …on he par where i have to disable some users i can seem to find any user that needs o be disabled can you point me to where i can find he users …because i have searched


all OU

Hi @etinosa4good

This task is based on the previous one. After creating the user accounts from the CSV file you will have some users. You will disable some of these recently created users.

Ricardo